Restore pero's timeout fix for the BIO connector. Add configuration of the timeout.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 17 Jul 2010 23:57:23 +0000 (23:57 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 17 Jul 2010 23:57:23 +0000 (23:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@965150 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Connector.java
java/org/apache/catalina/connector/Request.java
java/org/apache/tomcat/util/net/JIoEndpoint.java
webapps/docs/changelog.xml
webapps/docs/config/ajp.xml
webapps/docs/config/http.xml

index 9fab812..2ae9b67 100644 (file)
@@ -95,6 +95,12 @@ public class Connector extends LifecycleMBeanBase  {
 
 
     /**
+     * Default timeout for asynchronous requests (ms).
+     */
+    protected  long asyncTimeout = 10000;
+
+
+    /**
      * The "enable DNS lookups" flag for this Connector.
      */
     protected boolean enableLookups = false;
@@ -339,6 +345,29 @@ public class Connector extends LifecycleMBeanBase  {
 
     
     /**
+     * Return the default timeout for async requests in ms.
+     */
+    public long getAsyncTimeout() {
+
+        return asyncTimeout;
+
+    }
+
+
+    /**
+     * Set the default timeout for async requests.
+     *
+     * @param allowTrace The new timeout in ms.
+     */
+    public void setAsyncTimeout(long asyncTimeout) {
+
+        this.asyncTimeout= asyncTimeout;
+        setProperty("asyncTimeout", String.valueOf(asyncTimeout));
+
+    }
+
+    
+    /**
      * Return the "enable DNS lookups" flag.
      */
     public boolean getEnableLookups() {
index c4c5d5d..168484e 100644 (file)
@@ -1560,7 +1560,11 @@ public class Request
         //TODO SERVLET3 - async - need to retrieve the ServletContext here
         //or just the webapp classloader associated with to do 
         //run with start(Runnable)
-        asyncContext.setHasOriginalRequestAndResponse(request==getRequest() && response==getResponse().getResponse());
+        asyncContext.setHasOriginalRequestAndResponse(request==getRequest() &&
+                response==getResponse().getResponse());
+        
+        asyncContext.setTimeout(getConnector().getAsyncTimeout());
+        
         return asyncContext;
     }
 
index 28b3eb5..b20a2d8 100644 (file)
@@ -394,11 +394,19 @@ public class JIoEndpoint extends AbstractEndpoint {
 
             // Start acceptor threads
             for (int i = 0; i < acceptorThreadCount; i++) {
-                Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i);
+                Thread acceptorThread = new Thread(new Acceptor(),
+                        getName() + "-Acceptor-" + i);
                 acceptorThread.setPriority(threadPriority);
                 acceptorThread.setDaemon(getDaemon());
                 acceptorThread.start();
             }
+            
+            // Start async timeout thread
+            Thread timeoutThread = new Thread(new AsyncTimeout(),
+                    getName() + "-AsyncTimeout");
+            timeoutThread.setPriority(threadPriority);
+            timeoutThread.setDaemon(true);
+            timeoutThread.start();
         }
     }
 
index ccb6ec4..71fa152 100644 (file)
         replaced, ensure that the new Set-Cookie header overwrites the old
         Set-Cookie header. (markt) 
       </fix>
+      <fix>
+        Create a thread to trigger asynchronous timeouts when using the BIO
+        connector, change the default timeout to 10s (was infinite) and make the 
+        default timeout configurable using the <code>asyncTimeout</code>
+        attribute on the connector. (pero/markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">
index 934d3a2..cd64535 100644 (file)
       HTTP method. If not specified, this attribute is set to false.</p>
     </attribute>
 
+    <attribute name="asyncTimeout" required="false">
+      <p>The default timeout for asynchronous requests in milliseconds. If not
+      specified, this attribute is set to 10000 (10 seconds).</p>
+    </attribute>
+
     <attribute name="enableLookups" required="false">
       <p>Set to <code>true</code> if you want calls to
       <code>request.getRemoteHost()</code> to perform DNS lookups in
index 70901c0..48aa991 100644 (file)
       HTTP method. If not specified, this attribute is set to false.</p>
     </attribute>
 
+    <attribute name="asyncTimeout" required="false">
+      <p>The default timeout for asynchronous requests in milliseconds. If not
+      specified, this attribute is set to 10000 (10 seconds).</p>
+    </attribute>
+
     <attribute name="enableLookups" required="false">
       <p>Set to <code>true</code> if you want calls to
       <code>request.getRemoteHost()</code> to perform DNS lookups in