From: markt
Date: Sat, 17 Jul 2010 23:57:23 +0000 (+0000)
Subject: Restore pero's timeout fix for the BIO connector. Add configuration of the timeout.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=63a061bb0adc2c3a1c0983408ab7317a73646626;p=tomcat7.0
Restore pero's timeout fix for the BIO connector. Add configuration of the timeout.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@965150 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/java/org/apache/catalina/connector/Connector.java b/java/org/apache/catalina/connector/Connector.java
index 9fab8124a..2ae9b673a 100644
--- a/java/org/apache/catalina/connector/Connector.java
+++ b/java/org/apache/catalina/connector/Connector.java
@@ -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() {
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index c4c5d5dc3..168484ecd 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -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;
}
diff --git a/java/org/apache/tomcat/util/net/JIoEndpoint.java b/java/org/apache/tomcat/util/net/JIoEndpoint.java
index 28b3eb56c..b20a2d8f3 100644
--- a/java/org/apache/tomcat/util/net/JIoEndpoint.java
+++ b/java/org/apache/tomcat/util/net/JIoEndpoint.java
@@ -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();
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ccb6ec44e..71fa152b1 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -172,6 +172,12 @@
replaced, ensure that the new Set-Cookie header overwrites the old
Set-Cookie header. (markt)
+
+ 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 asyncTimeout
+ attribute on the connector. (pero/markt)
+
diff --git a/webapps/docs/config/ajp.xml b/webapps/docs/config/ajp.xml
index 934d3a243..cd645356b 100644
--- a/webapps/docs/config/ajp.xml
+++ b/webapps/docs/config/ajp.xml
@@ -79,6 +79,11 @@
HTTP method. If not specified, this attribute is set to false.
+
+ The default timeout for asynchronous requests in milliseconds. If not
+ specified, this attribute is set to 10000 (10 seconds).
+
+
Set to true if you want calls to
request.getRemoteHost() to perform DNS lookups in
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index 70901c0e6..48aa991c4 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -79,6 +79,11 @@
HTTP method. If not specified, this attribute is set to false.
+
+ The default timeout for asynchronous requests in milliseconds. If not
+ specified, this attribute is set to 10000 (10 seconds).
+
+
Set to true if you want calls to
request.getRemoteHost() to perform DNS lookups in