Author: markt
Date: Wed Nov 6 20:17:24 2013
New Revision: 1539452
URL: http://svn.apache.org/r1539452
Log:
Make the time the internal executor waits for request processing threads to
terminate before continuing with the connector stop process configurable.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
tomcat/trunk/webapps/docs/config/ajp.xml
tomcat/trunk/webapps/docs/config/http.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1539452&r1=1539451&r2=1539452&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Wed Nov
6 20:17:24 2013
@@ -135,6 +135,7 @@ public abstract class AbstractEndpoint<S
*/
protected volatile boolean internalExecutor = false;
+
/**
* counter for nr of connections handled by an endpoint
*/
@@ -157,9 +158,26 @@ public abstract class AbstractEndpoint<S
// -----------------------------------------------------------------
Properties
/**
+ * Time to wait for the internal executor (if used) to terminate when the
+ * endpoint is stopped in milliseconds. Defaults to 5000 (5 seconds).
+ */
+ private long executorTerminationTimeoutMillis = 5000;
+
+ public long getExecutorTerminationTimeoutMillis() {
+ return executorTerminationTimeoutMillis;
+ }
+
+ public void setExecutorTerminationTimeoutMillis(
+ long executorTerminationTimeoutMillis) {
+ this.executorTerminationTimeoutMillis =
executorTerminationTimeoutMillis;
+ }
+
+
+ /**
* Acceptor thread count.
*/
protected int acceptorThreadCount = 0;
+
public void setAcceptorThreadCount(int acceptorThreadCount) {
this.acceptorThreadCount = acceptorThreadCount;
}
@@ -521,7 +539,8 @@ public abstract class AbstractEndpoint<S
ThreadPoolExecutor tpe = (ThreadPoolExecutor) executor;
tpe.shutdownNow();
try {
- tpe.awaitTermination(5000, TimeUnit.MILLISECONDS);
+ tpe.awaitTermination(getExecutorTerminationTimeoutMillis(),
+ TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
// Ignore
}
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=1539452&r1=1539451&r2=1539452&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Wed Nov 6
20:17:24 2013
@@ -73,6 +73,9 @@ public class JIoEndpoint extends Abstrac
// Set maxConnections to zero so we can tell if the user has specified
// their own value on the connector when we reach bind()
setMaxConnections(0);
+ // Reduce the executor timeout for BIO as threads in keep-alive will
not
+ // terminate when the executor interrupts them.
+ setExecutorTerminationTimeoutMillis(0);
}
// ------------------------------------------------------------- Properties
Modified: tomcat/trunk/webapps/docs/config/ajp.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/ajp.xml?rev=1539452&r1=1539451&r2=1539452&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/ajp.xml (original)
+++ tomcat/trunk/webapps/docs/config/ajp.xml Wed Nov 6 20:17:24 2013
@@ -339,6 +339,14 @@
provide the thread pool.</p>
</attribute>
+ <attribute name="executorTerminationTimeoutMillis" required="false">
+ <p>The time that the private internal executor will wait for request
+ processing threads to terminate before continuing with the process of
+ stopping the connector. If not set, the default is <code>0</code> (zero)
+ for the BIO connector and <code>5000</code> (5 seconds) for the NIO and
+ APR/native connectors.</p>
+ </attribute>
+
<attribute name="keepAliveTimeout" required="false">
<p>The number of milliseconds this <strong>Connector</strong> will wait
for
another AJP request before closing the connection.
Modified: tomcat/trunk/webapps/docs/config/http.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/http.xml?rev=1539452&r1=1539451&r2=1539452&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/http.xml (original)
+++ tomcat/trunk/webapps/docs/config/http.xml Wed Nov 6 20:17:24 2013
@@ -376,6 +376,14 @@
provide the thread pool.</p>
</attribute>
+ <attribute name="executorTerminationTimeoutMillis" required="false">
+ <p>The time that the private internal executor will wait for request
+ processing threads to terminate before continuing with the process of
+ stopping the connector. If not set, the default is <code>0</code> (zero)
+ for the BIO connector and <code>5000</code> (5 seconds) for the NIO and
+ APR/native connectors.</p>
+ </attribute>
+
<attribute name="keepAliveTimeout" required="false">
<p>The number of milliseconds this <strong>Connector</strong> will wait
for another HTTP request before closing the connection. The default value
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]