Author: markt Date: Fri Apr 25 20:39:27 2014 New Revision: 1590135 URL: http://svn.apache.org/r1590135 Log: Stop threads used for secure WebSocket client connections when they are no longer required and give them better names for easier debugging while they are running.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1590128 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java?rev=1590135&r1=1590134&r2=1590135&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java Fri Apr 25 20:39:27 2014 @@ -26,9 +26,11 @@ import java.util.concurrent.ExecutionExc import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult; @@ -57,7 +59,8 @@ public class AsyncChannelWrapperSecure i private final ByteBuffer socketReadBuffer; private final ByteBuffer socketWriteBuffer; // One thread for read, one for write - private final ExecutorService executor = Executors.newFixedThreadPool(2); + private final ExecutorService executor = + Executors.newFixedThreadPool(2, new SecureIOThreadFactory()); private AtomicBoolean writing = new AtomicBoolean(false); private AtomicBoolean reading = new AtomicBoolean(false); @@ -148,6 +151,7 @@ public class AsyncChannelWrapperSecure i } catch (IOException e) { log.info(sm.getString("asyncChannelWrapperSecure.closeFail")); } + executor.shutdownNow(); } @Override @@ -555,4 +559,19 @@ public class AsyncChannelWrapperSecure i return new Integer(result.intValue()); } } + + + private static class SecureIOThreadFactory implements ThreadFactory { + + private AtomicInteger count = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r); + t.setName("WebSocketClient-SecureIO-" + count.incrementAndGet()); + t.setContextClassLoader(this.getClass().getClassLoader()); + t.setDaemon(true); + return t; + } + } } Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1590135&r1=1590134&r2=1590135&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Apr 25 20:39:27 2014 @@ -221,6 +221,11 @@ <bug>56458</bug>: Report WebSocket sessions that are created over secure connections as secure rather than as not secure. (markt) </fix> + <fix> + Stop threads used for secure WebSocket client connections when they are + no longer required and give them better names for easier debugging while + they are running. (markt) + </fix> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org