Author: markt
Date: Tue May 13 11:26:26 2014
New Revision: 1594199
URL: http://svn.apache.org/r1594199
Log:
Give the thread shutting down the existing connections a chance to finish
before forcibly closing them and triggering an exception on each connection
that is forcibly closed.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1594199&r1=1594198&r2=1594199&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Tue May 13
11:26:26 2014
@@ -90,6 +90,8 @@ public class Nio2Endpoint extends Abstra
*/
private AsynchronousChannelGroup threadGroup = null;
+ private volatile boolean allClosed;
+
/**
* The oom parachute, when an OOM error happens,
* will release the data, giving the JVM instantly
@@ -347,6 +349,7 @@ public class Nio2Endpoint extends Abstra
public void startInternal() throws Exception {
if (!running) {
+ allClosed = false;
running = true;
paused = false;
@@ -398,6 +401,8 @@ public class Nio2Endpoint extends Abstra
handler.closeAll();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
+ } finally {
+ allClosed = true;
}
}
});
@@ -431,8 +436,12 @@ public class Nio2Endpoint extends Abstra
public void shutdownExecutor() {
if (threadGroup != null && internalExecutor) {
try {
- threadGroup.shutdownNow();
long timeout = getExecutorTerminationTimeoutMillis();
+ while (timeout > 0 && !allClosed) {
+ timeout -= 100;
+ Thread.sleep(100);
+ }
+ threadGroup.shutdownNow();
if (timeout > 0) {
threadGroup.awaitTermination(timeout,
TimeUnit.MILLISECONDS);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]