From: markt Date: Tue, 24 Aug 2010 18:12:51 +0000 (+0000) Subject: Fix some edge cases in the NIO connector when handling requests that are not received... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0430381232122b8d60052d87d5a47a5912f0f374;p=tomcat7.0 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. 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 --- diff --git a/java/org/apache/coyote/http11/Http11NioProcessor.java b/java/org/apache/coyote/http11/Http11NioProcessor.java index 8421173e8..d86758bd9 100644 --- a/java/org/apache/coyote/http11/Http11NioProcessor.java +++ b/java/org/apache/coyote/http11/Http11NioProcessor.java @@ -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; } diff --git a/java/org/apache/coyote/http11/Http11NioProtocol.java b/java/org/apache/coyote/http11/Http11NioProtocol.java index 364830521..ba7562170 100644 --- a/java/org/apache/coyote/http11/Http11NioProtocol.java +++ b/java/org/apache/coyote/http11/Http11NioProtocol.java @@ -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; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index feecb2d71..a855ddf8f 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -92,6 +92,11 @@ Follow up to 48545. Make JSSE connectors more tolerant of a incorrect trust store password. (markt) + + 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) +