Author: markt Date: Wed Jan 26 16:11:46 2011 New Revision: 1063774 URL: http://svn.apache.org/viewvc?rev=1063774&view=rev Log: Don't assume servlet 3+ async when processing long poll connections (it might be comet) Use socket rather than socket wrapper as key in connection list else comet sockets may be lost
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1063774&r1=1063773&r2=1063774&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Wed Jan 26 16:11:46 2011 @@ -204,8 +204,8 @@ public class Http11AprProtocol extends A protected AtomicLong registerCount = new AtomicLong(0); protected RequestGroupInfo global = new RequestGroupInfo(); - protected ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor> connections = - new ConcurrentHashMap<SocketWrapper<Long>, Http11AprProcessor>(); + protected ConcurrentHashMap<Long, Http11AprProcessor> connections = + new ConcurrentHashMap<Long, Http11AprProcessor>(); protected ConcurrentLinkedQueue<Http11AprProcessor> recycledProcessors = new ConcurrentLinkedQueue<Http11AprProcessor>() { @@ -264,7 +264,7 @@ public class Http11AprProtocol extends A @Override public SocketState event(SocketWrapper<Long> socket, SocketStatus status) { - Http11AprProcessor processor = connections.get(socket); + Http11AprProcessor processor = connections.get(socket.getSocket()); SocketState state = SocketState.CLOSED; if (processor != null) { @@ -294,7 +294,7 @@ public class Http11AprProtocol extends A "http11protocol.proto.error"), e); } finally { if (state != SocketState.LONG) { - connections.remove(socket); + connections.remove(socket.getSocket()); socket.setAsync(false); recycledProcessors.offer(processor); if (state == SocketState.OPEN) { @@ -329,8 +329,13 @@ public class Http11AprProtocol extends A if (state == SocketState.LONG || state == SocketState.ASYNC_END) { // Need to make socket available for next processing cycle // but no need for the poller - connections.put(socket, processor); - socket.setAsync(true); + connections.put(socket.getSocket(), processor); + if (processor.isAsync()) { + socket.setAsync(true); + } else if (processor.comet) { + ((AprEndpoint) proto.endpoint).getCometPoller().add( + socket.getSocket().longValue()); + } } else { recycledProcessors.offer(processor); } @@ -362,7 +367,7 @@ public class Http11AprProtocol extends A @Override public SocketState asyncDispatch(SocketWrapper<Long> socket, SocketStatus status) { - Http11AprProcessor result = connections.get(socket); + Http11AprProcessor result = connections.get(socket.getSocket()); SocketState state = SocketState.CLOSED; if (result != null) { Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1063774&r1=1063773&r2=1063774&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Jan 26 16:11:46 2011 @@ -1688,7 +1688,9 @@ public class AprEndpoint extends Abstrac socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); - waitingRequests.add(socket); + if (socket.async) { + waitingRequests.add(socket); + } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN); Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1063774&r1=1063773&r2=1063774&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jan 26 16:11:46 2011 @@ -118,6 +118,10 @@ <bug>50627</bug>: Correct interaction of NIO socket and Poller when processing Comet events. (markt) </fix> + <fix> + Correct interaction of APR socket and Poller when processing Comet + events. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org