Author: markt Date: Tue Jan 25 17:20:20 2011 New Revision: 1063366 URL: http://svn.apache.org/viewvc?rev=1063366&view=rev Log: Fix various odd behaviours seen with a debugger. Observed both multiple and zero (rather than 1) selection events for a single data receive event
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1063366&r1=1063365&r2=1063366&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Tue Jan 25 17:20:20 2011 @@ -17,6 +17,8 @@ package org.apache.coyote.http11; +import java.io.IOException; +import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.security.AccessController; import java.security.PrivilegedAction; @@ -317,8 +319,10 @@ public class Http11NioProtocol extends A } else { // Comet if (log.isDebugEnabled()) log.debug("Keeping processor["+processor); - //add correct poller events here based on Comet stuff - socket.getPoller().add(socket,att.getCometOps()); + // May receive more data from client + SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector()); + key.interestOps(SelectionKey.OP_READ); + att.interestOps(SelectionKey.OP_READ); } } else { // state == SocketState.ASYNC_END @@ -358,8 +362,11 @@ public class Http11NioProtocol extends A connections.put(socket, processor); if (processor.comet) { + // May receive more data from client + SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector()); NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false); - socket.getPoller().add(socket,att.getCometOps()); + key.interestOps(SelectionKey.OP_READ); + att.interestOps(SelectionKey.OP_READ); } else if (processor.isAsync()) { NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false); att.setAsync(true); @@ -367,7 +374,10 @@ public class Http11NioProtocol extends A // complete or dispatch) state = processor.asyncPostProcess(); } else { - socket.getPoller().add(socket); + // Error condition. A connection in this state should + // by using one of async or comet + throw new IOException(sm.getString( + "http11protocol.state.long.error")); } } if (state == SocketState.LONG || state == SocketState.ASYNC_END) { Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties?rev=1063366&r1=1063365&r2=1063366&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties Tue Jan 25 17:20:20 2011 @@ -20,6 +20,7 @@ http11protocol.proto.ioexception.info=IO http11protocol.proto.socketexception.debug=SocketException reading request http11protocol.proto.socketexception.info=SocketException reading request, ignored http11protocol.start=Starting Coyote HTTP/1.1 on {0} +http11protocol.state.long.error=Error processing request. Socket is in the long poll state but neither Servlet 3.0+ async or Comet is being used http11processor.regexp.error=Error parsing regular expression {0} http11processor.filter.unknown=Unknown filter {0} Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1063366&r1=1063365&r2=1063366&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Tue Jan 25 17:20:20 2011 @@ -114,6 +114,10 @@ Ensure correct recycling of NIO input filters when processing Comet events. (markt) </fix> + <fix> + Correct interaction of NIO 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