Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50158
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 16 Apr 2011 23:41:32 +0000 (23:41 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 16 Apr 2011 23:41:32 +0000 (23:41 +0000)
Ensure the asynchronous requests never timeout if the timeout is set to zero or less.
Based on a patch provided by Chris.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1094088 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AprEndpoint.java
java/org/apache/tomcat/util/net/JIoEndpoint.java
java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/SocketProperties.java
webapps/docs/changelog.xml

index 53dd024..194e18c 100644 (file)
@@ -1024,7 +1024,8 @@ public class AprEndpoint extends AbstractEndpoint {
                     SocketWrapper<Long> socket = sockets.next();
                     if (socket.async) {
                         long access = socket.getLastAccess();
-                        if ((now-access)>socket.getTimeout()) {
+                        if (socket.getTimeout() > 0 &&
+                                (now-access)>socket.getTimeout()) {
                             processSocketAsync(socket,SocketStatus.TIMEOUT);
                         }
                     }
index 3e97b4e..4507430 100644 (file)
@@ -150,7 +150,8 @@ public class JIoEndpoint extends AbstractEndpoint {
                 while (sockets.hasNext()) {
                     SocketWrapper<Socket> socket = sockets.next();
                     long access = socket.getLastAccess();
-                    if ((now-access)>socket.getTimeout()) {
+                    if (socket.getTimeout() > 0 &&
+                            (now-access)>socket.getTimeout()) {
                         processSocketAsync(socket,SocketStatus.TIMEOUT);
                     }
                 }
index 0d751e7..775b8bb 100644 (file)
@@ -1344,13 +1344,16 @@ public class NioEndpoint extends AbstractEndpoint {
                             nextExpiration = (nextTime < nextExpiration)?nextTime:nextExpiration;
                         }
                     } 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;
-                        if (isTimedout) {
-                            // Prevent subsequent timeouts if the timeout event takes a while to process
-                            ka.access(Long.MAX_VALUE);
-                            processSocket(ka.getChannel(), SocketStatus.TIMEOUT, true);
+                        // Async requests with a timeout of 0 or less never timeout
+                        if (!ka.isAsync() || ka.getTimeout() > 0) {
+                            long delta = now - ka.getLastAccess();
+                            long timeout = (ka.getTimeout()==-1)?((long) socketProperties.getSoTimeout()):(ka.getTimeout());
+                            boolean isTimedout = delta > timeout;
+                            if (isTimedout) {
+                                // Prevent subsequent timeouts if the timeout event takes a while to process
+                                ka.access(Long.MAX_VALUE);
+                                processSocket(ka.getChannel(), SocketStatus.TIMEOUT, true);
+                            }
                         }
                     }//end if
                 }catch ( CancelledKeyException ckx ) {
index 66a2101..b436380 100644 (file)
@@ -173,8 +173,8 @@ public class SocketProperties {
     protected Integer performanceBandwidth = null;
     
     /**
-     * The minimum frequency of the timeout interval to avoid the 
-     * poller going boinkers during high traffic
+     * The minimum frequency of the timeout interval to avoid excess load from
+     * the poller during high traffic
      */
     protected long timeoutInterval = 1000;
     
index 6e98e2b..5852523 100644 (file)
         <bug>50957</bug>: Fix regression in HTTP BIO connector that triggered
         errors when processing pipe-lined requests. (markt)
       </fix>
+      <fix>
+        <bug>50158</bug>: Ensure the asynchronous requests never timeout if the
+        timeout is set to zero or less. Based on a patch provided by Chris.
+        (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">