Align the process methods some more.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Jul 2011 11:40:36 +0000 (11:40 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Jul 2011 11:40:36 +0000 (11:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1144271 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProtocol.java
java/org/apache/coyote/ajp/AjpNioProtocol.java
java/org/apache/coyote/ajp/AjpProtocol.java
java/org/apache/tomcat/util/net/AbstractEndpoint.java

index f1152bf..661b68e 100644 (file)
@@ -174,7 +174,6 @@ public class AjpAprProtocol extends AbstractAjpProtocol {
                     recycledProcessors.offer(processor);
                 }
                 return state;
-
             } catch(java.net.SocketException e) {
                 // SocketExceptions are normal
                 log.debug(sm.getString(
index 0d9299e..1a04b66 100644 (file)
@@ -206,7 +206,6 @@ public class AjpNioProtocol extends AbstractAjpProtocol {
                     // In the middle of processing a request/response. Keep the
                     // socket associated with the processor.
                     connections.put(socket, processor);
-                    
                     socket.setAsync(true);
                 } else if (state == SocketState.OPEN){
                     // In keep-alive but between requests. OK to recycle
@@ -218,7 +217,6 @@ public class AjpNioProtocol extends AbstractAjpProtocol {
                     release(socket, processor, true);
                 }
                 return state;
-
             } catch(java.net.SocketException e) {
                 // SocketExceptions are normal
                 log.debug(sm.getString(
index 75c9436..111d1a8 100644 (file)
@@ -125,8 +125,12 @@ public class AjpProtocol extends AbstractAjpProtocol {
         }
         
         @Override
-        public SocketState process(SocketWrapper<Socket> socket, SocketStatus status) {
+        public SocketState process(SocketWrapper<Socket> socket,
+                SocketStatus status) {
             AjpProcessor processor = connections.remove(socket);
+
+            socket.setAsync(false);
+
             try {
                 if (processor == null) {
                     processor = recycledProcessors.poll();
@@ -147,12 +151,15 @@ public class AjpProtocol extends AbstractAjpProtocol {
                         state = processor.asyncPostProcess();
                     }
                 } while (state == SocketState.ASYNC_END);
-                // TODO Better to add a new state to the AsyncStateMachine and
-                //      remove ASYNC_END entirely
 
                 if (state == SocketState.LONG) {
+                    // In the middle of processing a request/response. Keep the
+                    // socket associated with the processor.
                     connections.put(socket, processor);
+                    socket.setAsync(true);
                 } else if (state == SocketState.OPEN){
+                    // In keep-alive but between requests. OK to recycle
+                    // processor. Continue to poll for the next request.
                     processor.recycle(false);
                     recycledProcessors.offer(processor);
                 } else {
index 606923d..1b45069 100644 (file)
@@ -52,6 +52,8 @@ public abstract class AbstractEndpoint {
          * Different types of socket states to react upon.
          */
         public enum SocketState {
+            // TODO Add a new state to the AsyncStateMachine and remove
+            //      ASYNC_END (if possible)
             OPEN, CLOSED, LONG, ASYNC_END
         }