Fix some edge cases in the NIO connector when handling requests that are not received...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 24 Aug 2010 18:12:51 +0000 (18:12 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 24 Aug 2010 18:12:51 +0000 (18:12 +0000)
This should fix the current Gump failures in the NIO tests.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@988645 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11NioProcessor.java
java/org/apache/coyote/http11/Http11NioProtocol.java
webapps/docs/changelog.xml

index 8421173..d86758b 100644 (file)
@@ -308,13 +308,18 @@ public class Http11NioProcessor extends AbstractHttp11Processor implements Actio
                     socket.getIOChannel().socket().setSoTimeout((int)soTimeout);
                 }
                 if (!inputBuffer.parseRequestLine(keptAlive)) {
-                    //no data available yet, since we might have read part
-                    //of the request line, we can't recycle the processor
+                    // Haven't finished reading the request so keep the socket
+                    // open
                     openSocket = true;
-                    recycle = false;
+                    // Check to see if we have read any of the request line yet
                     if (inputBuffer.getParsingRequestLinePhase()<2) {
-                        //keep alive timeout here
+                        // No data read, OK to recycle the processor
+                        // Continue to use keep alive timeout
                         if (keepAliveTimeout>0) ka.setTimeout(keepAliveTimeout);
+                    } else {
+                        // Started to read request line. Need to keep processor
+                        // associated with socket
+                        recycle = false;
                     }
                     break;
                 }
index 3648305..ba75621 100644 (file)
@@ -365,10 +365,8 @@ public class Http11NioProtocol extends AbstractHttp11Protocol {
 
                 SocketState state = processor.process(socket);
                 if (state == SocketState.LONG) {
-                    // Associate the connection with the processor. The next request 
-                    // processed by this thread will use either a new or a recycled
-                    // processor.
-                    //if (log.isDebugEnabled()) log.debug("Not recycling ["+processor+"] Comet="+((NioEndpoint.KeyAttachment)socket.getAttachment(false)).getComet());
+                    // In the middle of processing a request/response. Keep the
+                    // socket associated with the processor.
                     connections.put(socket, processor);
                     
                     if (processor.comet) {
@@ -378,11 +376,15 @@ public class Http11NioProtocol extends AbstractHttp11Protocol {
                         NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
                         att.setAsync(true);
                     } else {
-                        //we should not hold on to the processor objects
-                        release(socket);
                         socket.getPoller().add(socket);
                     }
+                } else if (state == SocketState.OPEN){
+                    // In keep-alive but between requests. OK to recycle
+                    // processor. Continue to poll for the next request.
+                    socket.getPoller().add(socket);
+                    recycledProcessors.offer(processor);
                 } else {
+                    // Connection closed. OK to recycle the processor.
                     recycledProcessors.offer(processor);
                 }
                 return state;
index feecb2d..a855ddf 100644 (file)
         Follow up to <bug>48545</bug>. Make JSSE connectors more tolerant of a
         incorrect trust store password. (markt)
       </add>
+      <fix>
+        Fix some edge cases in the NIO connector when handling requests that are
+        not received all at the same time and the socket needs to be returned to
+        the poller. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">