Author: fhanik
Date: Mon Mar  8 16:38:35 2010
New Revision: 920392

URL: http://svn.apache.org/viewvc?rev=920392&view=rev
Log:
more work towards making the JIO connector ready for async

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=920392&r1=920391&r2=920392&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Mon Mar  8 
16:38:35 2010
@@ -185,12 +185,13 @@
             error = true;
         }
 
-        boolean keptAlive = false;
+        boolean keptAlive = socketWrapper.isKeptAlive();
 
         while (started && !error && keepAlive) {
 
             // Parsing the request header
             try {
+                //TODO - calculate timeout based on length in queue 
(System.currentTimeMills() - wrapper.getLastAccess() is the time in queue)
                 if (keptAlive) {
                     if (keepAliveTimeout > 0) {
                         socket.setSoTimeout(keepAliveTimeout);

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=920392&r1=920391&r2=920392&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Mon Mar  8 
16:38:35 2010
@@ -187,10 +187,12 @@
         public void run() {
                boolean close = false;
             // Process the request from this socket
-            if (!setSocketOptions(socket.getSocket())) { //this does a 
handshake and resets socket value
+            if ( (!socket.isKeptAlive()) && 
(!setSocketOptions(socket.getSocket())) ) { //this does a handshake and resets 
socket value
                close = true;
-            } else if (!handler.process(socket)) {
-                close = true;
+            }
+            
+            if ( (!close) ) {
+                close = !handler.process(socket);
             }
             if (close) {
                // Close socket
@@ -203,7 +205,10 @@
                     // Ignore
                 }
             } else {
+                socket.setKeptAlive(true);
+                socket.access();
                 //keepalive connection
+                //TODO - servlet3 check async status, we may just be in a hold 
pattern
                 getExecutor().execute(new SocketProcessor(socket));
             }
             // Finish up this request

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java?rev=920392&r1=920391&r2=920392&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java Mon Mar  8 
16:38:35 2010
@@ -21,13 +21,14 @@
     
     protected volatile E socket;
     
-    protected long lastAccess = -1;
-    protected boolean currentAccess = false;
+    protected volatile long lastAccess = -1;
+    protected volatile boolean currentAccess = false;
     protected long timeout = -1;
     protected boolean error = false;
     protected long lastRegistered = 0;
     protected volatile int keepAliveLeft = 100;
     protected boolean async = false;
+    protected boolean keptAlive = false;
     
     public SocketWrapper(E socket) {
         reset(socket);
@@ -55,5 +56,6 @@
     public int getKeepAliveLeft() { return this.keepAliveLeft; }
     public void setKeepAliveLeft(int keepAliveLeft) { this.keepAliveLeft = 
keepAliveLeft;}
     public int decrementKeepAlive() { return (--keepAliveLeft);}
-
+    public boolean isKeptAlive() {return keptAlive;}
+    public void setKeptAlive(boolean keptAlive) {this.keptAlive = keptAlive;}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to