Author: remm Date: Tue Apr 1 16:37:24 2014 New Revision: 1583731 URL: http://svn.apache.org/r1583731 Log: Cleanup waiting async connections on shutdown, to avoid any abrupt close if everything is well behaved.
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java tomcat/trunk/webapps/docs/changelog.xml 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=1583731&r1=1583730&r2=1583731&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Tue Apr 1 16:37:24 2014 @@ -385,11 +385,23 @@ public class Nio2Endpoint extends Abstra running = false; unlockAccept(); } - try { - handler.closeAll(); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - } + // Use the executor to avoid binding the main thread if something bad + // occurs and unbind will also wait for a bit for it to complete + getExecutor().execute(new Runnable() { + @Override + public void run() { + // Timeout any pending async request + for (SocketWrapper<Nio2Channel> socket : waitingRequests.keySet()) { + processSocket(socket, SocketStatus.TIMEOUT, false); + } + // Then close all active connections if any remains + try { + handler.closeAll(); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + } + } + }); if (useCaches) { socketWrapperCache.clear(); nioChannels.clear(); Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1583731&r1=1583730&r2=1583731&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Tue Apr 1 16:37:24 2014 @@ -72,6 +72,13 @@ </fix> </changelog> </subsection> + <subsection name="Coyote"> + <changelog> + <fix> + More cleanup of NIO2 endpoint shutdown. (remm) + </fix> + </changelog> + </subsection> <subsection name="Cluster"> <changelog> <scode> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org