Author: markt
Date: Sat Jul 17 23:57:23 2010
New Revision: 965150

URL: http://svn.apache.org/viewvc?rev=965150&view=rev
Log:
Restore pero's timeout fix for the BIO connector. Add configuration of the 
timeout.

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

Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Sat Jul 17 
23:57:23 2010
@@ -95,6 +95,12 @@ public class Connector extends Lifecycle
 
 
     /**
+     * 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 Lifecycle
 
     
     /**
+     * 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() {

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Sat Jul 17 
23:57:23 2010
@@ -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;
     }
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Sat Jul 17 
23:57:23 2010
@@ -394,11 +394,19 @@ public class JIoEndpoint extends Abstrac
 
             // 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();
         }
     }
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sat Jul 17 23:57:23 2010
@@ -172,6 +172,12 @@
         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">

Modified: tomcat/trunk/webapps/docs/config/ajp.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/ajp.xml?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/ajp.xml (original)
+++ tomcat/trunk/webapps/docs/config/ajp.xml Sat Jul 17 23:57:23 2010
@@ -79,6 +79,11 @@
       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

Modified: tomcat/trunk/webapps/docs/config/http.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/http.xml?rev=965150&r1=965149&r2=965150&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/http.xml (original)
+++ tomcat/trunk/webapps/docs/config/http.xml Sat Jul 17 23:57:23 2010
@@ -79,6 +79,11 @@
       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



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to