Fix Async with APR and TCP_DEFER_ACCEPT
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 9 Mar 2011 22:36:55 +0000 (22:36 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 9 Mar 2011 22:36:55 +0000 (22:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1080040 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AprEndpoint.java
webapps/docs/changelog.xml

index e0649b4..3eb997d 100644 (file)
@@ -760,7 +760,8 @@ public class AprEndpoint extends AbstractEndpoint {
             if (running) {
                 SocketWrapper<Long> wrapper =
                     new SocketWrapper<Long>(Long.valueOf(socket));
-                getExecutor().execute(new SocketWithOptionsProcessor(wrapper));
+                getExecutor().execute(
+                        new SocketWithOptionsProcessor(wrapper, null));
             }
         } catch (RejectedExecutionException x) {
             log.warn("Socket processing request was rejected for:"+socket,x);
@@ -1641,9 +1642,13 @@ public class AprEndpoint extends AbstractEndpoint {
     protected class SocketWithOptionsProcessor implements Runnable {
 
         protected SocketWrapper<Long> socket = null;
+        protected SocketStatus status = null;
+
 
-        public SocketWithOptionsProcessor(SocketWrapper<Long> socket) {
+        public SocketWithOptionsProcessor(SocketWrapper<Long> socket,
+                SocketStatus status) {
             this.socket = socket;
+            this.status = status;
         }
 
         @Override
@@ -1660,17 +1665,30 @@ public class AprEndpoint extends AbstractEndpoint {
                     }
                 } else {
                     // Process the request from this socket
-                    if (!setSocketOptions(socket.getSocket().longValue())
-                            || handler.process(socket) == Handler.SocketState.CLOSED) {
+                    if (!setSocketOptions(socket.getSocket().longValue())) {
                         // Close socket and pool
                         destroySocket(socket.getSocket().longValue());
                         socket = null;
                     }
+                    // Process the request from this socket
+                    Handler.SocketState state = (status==null)?handler.process(socket):handler.asyncDispatch(socket, status);
+                    if (state == Handler.SocketState.CLOSED) {
+                        // Close socket and pool
+                        destroySocket(socket.getSocket().longValue());
+                        socket = null;
+                    } else if (state == Handler.SocketState.LONG) {
+                        socket.access();
+                        if (socket.async) {
+                            waitingRequests.add(socket);
+                        }
+                    } else if (state == Handler.SocketState.ASYNC_END) {
+                        socket.access();
+                        SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN);
+                        getExecutor().execute(proc);
+                    }
                 }
             }
-
         }
-
     }
 
 
index def51e5..39a5912 100644 (file)
         <bug>48208</bug>: Allow the configuration of a custom trust manager for
         use in CLIENT-CERT authentication. (markt)
       </add>
+      <fix>
+        Fix issues that prevented asynchronous servlets from working when used
+        with the HTTP APR connector on platforms that support TCP_DEFER_ACCEPT.
+        (martk)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">