Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50207
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 16:57:47 +0000 (16:57 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Nov 2010 16:57:47 +0000 (16:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1038202 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/tomcat/util/net/NioEndpoint.java
webapps/docs/changelog.xml

index c10e0e9..2d36591 100644 (file)
@@ -329,19 +329,23 @@ public class Http11NioProtocol extends AbstractHttp11JsseProtocol {
                     if (processor.isAsync()) {
                         state = processor.asyncPostProcess();
                     }
-                    if (state != SocketState.LONG && state != SocketState.ASYNC_END) {
+                    if (state == SocketState.OPEN || state == SocketState.CLOSED) {
                         release(socket);
                         if (state == SocketState.OPEN) {
                             socket.getPoller().add(socket);
                         }
-                    } else if (state == SocketState.ASYNC_END) {
-                        // No further work required
                     } else if (state == SocketState.LONG) {
-                        att.setAsync(true); // Re-enable timeouts
+                        if (processor.isAsync()) {
+                            att.setAsync(true); // Re-enable timeouts
+                        } 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());
+                        }
                     } else {
-                        if (log.isDebugEnabled()) log.debug("Keeping processor["+processor);
-                        //add correct poller events here based on Comet stuff
-                        socket.getPoller().add(socket,att.getCometOps());
+                        // state == SocketState.ASYNC_END
+                        // No further work required
                     }
                 }
             }
index a657192..de91ba1 100644 (file)
@@ -1322,7 +1322,7 @@ public class NioEndpoint extends AbstractEndpoint {
                         reg(key,ka,0);//avoid multiple calls, this gets reregistered after invocation
                         //if (!processSocket(ka.getChannel(), SocketStatus.OPEN_CALLBACK)) processSocket(ka.getChannel(), SocketStatus.DISCONNECT);
                         if (!processSocket(ka.getChannel(), SocketStatus.OPEN, true)) processSocket(ka.getChannel(), SocketStatus.DISCONNECT, true);
-                    }else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ ||
+                    } else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ ||
                               (ka.interestOps()&SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
                         //only timeout sockets that we are waiting for a read from
                         long delta = now - ka.getLastAccess();
@@ -1340,7 +1340,7 @@ public class NioEndpoint extends AbstractEndpoint {
                             long nextTime = now+(timeout-delta);
                             nextExpiration = (nextTime < nextExpiration)?nextTime:nextExpiration;
                         }
-                    }else if (ka.isAsync()) {
+                    } else if (ka.isAsync() || ka.getComet()) {
                         long delta = now - ka.getLastAccess();
                         long timeout = (ka.getTimeout()==-1)?((long) socketProperties.getSoTimeout()):(ka.getTimeout());
                         boolean isTimedout = delta > timeout;
index b55c190..aca59a5 100644 (file)
         is configurable with a system property and is <code>8192</code>
         by default. (kkolinko)
       </add>
+      <fix>
+        <bug>50207</bug>: Ensure Comet timeout events are triggered. This bug
+        was a regression triggered by the fix for <bug>49884</bug>. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">