Align request processing between the connectors
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 5 Sep 2011 15:31:46 +0000 (15:31 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 5 Sep 2011 15:31:46 +0000 (15:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1165338 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/AbstractHttp11Processor.java
java/org/apache/coyote/http11/Http11AprProcessor.java
java/org/apache/coyote/http11/Http11NioProcessor.java
java/org/apache/coyote/http11/Http11Processor.java

index 48aaed4..d5a602c 100644 (file)
@@ -1291,6 +1291,12 @@ public abstract class AbstractHttp11Processor<S> extends AbstractProcessor<S> {
     protected abstract void resetTimeouts();
 
 
+    /**
+     * Provides a mechanism for those connectors (currently only NIO) that need
+     * that need to set comment timeouts.
+     */
+    protected abstract void setCometTimeouts(SocketWrapper<S> socketWrapper);
+
     public void endRequest() {
 
         // Finish the handling of the request
index f413559..907938b 100644 (file)
@@ -278,6 +278,7 @@ public class Http11AprProcessor extends AbstractHttp11Processor<Long> {
                                 (!isAsync() &&
                                 statusDropsConnection(response.getStatus()));
                     }
+                    setCometTimeouts(socketWrapper);
                 } catch (InterruptedIOException e) {
                     error = true;
                 } catch (Throwable t) {
@@ -350,6 +351,13 @@ public class Http11AprProcessor extends AbstractHttp11Processor<Long> {
 
 
     @Override
+    protected void setCometTimeouts(SocketWrapper<Long> socketWrapper) {
+       // NO-OP for APR/native
+       return;
+    }
+
+
+    @Override
     protected boolean breakKeepAliveLoop(SocketWrapper<Long> socketWrapper) {
         // Do sendfile as needed: add socket to sendfile and end
         if (sendfileData != null && !error) {
index 6345996..437f24d 100644 (file)
@@ -326,19 +326,7 @@ public class Http11NioProcessor extends AbstractHttp11Processor<NioChannel> {
                                 (!isAsync() &&
                                 statusDropsConnection(response.getStatus()));
                     }
-                    // Comet support
-                    SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
-                            socketWrapper.getSocket().getPoller().getSelector());
-                    if (key != null) {
-                        NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
-                        if (attach != null)  {
-                            attach.setComet(comet);
-                            if (comet) {
-                                Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
-                                if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
-                            }
-                        }
-                    }
+                    setCometTimeouts(socketWrapper);
                 } catch (InterruptedIOException e) {
                     error = true;
                 } catch (Throwable t) {
@@ -411,6 +399,24 @@ public class Http11NioProcessor extends AbstractHttp11Processor<NioChannel> {
 
 
     @Override
+    protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
+        // Comet support
+        SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
+                socketWrapper.getSocket().getPoller().getSelector());
+        if (key != null) {
+            NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment();
+            if (attach != null)  {
+                attach.setComet(comet);
+                if (comet) {
+                    Integer comettimeout = (Integer) request.getAttribute("org.apache.tomcat.comet.timeout");
+                    if (comettimeout != null) attach.setTimeout(comettimeout.longValue());
+                }
+            }
+        }
+    }
+
+
+    @Override
     protected boolean breakKeepAliveLoop(
             SocketWrapper<NioChannel> socketWrapper) {
         // Do sendfile as needed: add socket to sendfile and end
index acee819..b028cd2 100644 (file)
@@ -272,7 +272,7 @@ public class Http11Processor extends AbstractHttp11Processor<Socket> {
                                 (!isAsync() &&
                                 statusDropsConnection(response.getStatus()));
                     }
-
+                    setCometTimeouts(socketWrapper);
                 } catch (InterruptedIOException e) {
                     error = true;
                 } catch (Throwable t) {
@@ -345,6 +345,13 @@ public class Http11Processor extends AbstractHttp11Processor<Socket> {
 
 
     @Override
+    protected void setCometTimeouts(SocketWrapper<Socket> socketWrapper) {
+       // NO-OP for BIO
+       return;
+    }
+
+
+    @Override
     protected boolean breakKeepAliveLoop(SocketWrapper<Socket> socketWrapper) {
         // If we don't have a pipe-lined request allow this thread to be
         // used by another connection