Author: markt Date: Tue Mar 10 20:10:45 2015 New Revision: 1665672 URL: http://svn.apache.org/r1665672 Log: While looking at BZ 57653 I noticed a couple of places where modification to the addList and closeList was not protected by a sync. This could have led to corruption of these lists.
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1665672&r1=1665671&r2=1665672&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Mar 10 20:10:45 2015 @@ -1299,13 +1299,13 @@ public class AprEndpoint extends Abstrac /** * List of sockets to be added to the poller. */ - private SocketList addList = null; + private SocketList addList = null; // Modifications guarded by this /** * List of sockets to be closed. */ - private SocketList closeList = null; + private SocketList closeList = null; // Modifications guarded by this /** @@ -1340,7 +1340,7 @@ public class AprEndpoint extends Abstrac * Create the poller. With some versions of APR, the maximum poller size * will be 62 (recompiling APR is necessary to remove this limitation). */ - protected void init() { + protected synchronized void init() { pool = Pool.create(serverSockPool); @@ -1406,15 +1406,13 @@ public class AprEndpoint extends Abstrac /** * Destroy the poller. */ - protected void destroy() { + protected synchronized void destroy() { // Wait for pollerTime before doing anything, so that the poller // threads exit, otherwise parallel destruction of sockets which are // still in the poller can cause problems try { - synchronized (this) { - this.notify(); - this.wait(pollTime / 1000); - } + this.notify(); + this.wait(pollTime / 1000); } catch (InterruptedException e) { // Ignore } @@ -1568,7 +1566,7 @@ public class AprEndpoint extends Abstrac /** * Timeout checks. Must only be called from {@link Poller#run()}. */ - private void maintain() { + private synchronized void maintain() { long date = System.currentTimeMillis(); // Maintain runs at most once every 1s, although it will likely get @@ -1633,7 +1631,7 @@ public class AprEndpoint extends Abstrac // Ignore } } - // Check timeouts if the poller is empty + // Check timeouts if the poller is empty. while (pollerRunning && connectionCount.get() < 1 && addList.size() < 1 && closeList.size() < 1) { // Reset maintain time. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org