Author: markt
Date: Tue Mar 10 19:19:32 2015
New Revision: 1665653
URL: http://svn.apache.org/r1665653
Log:
While looking at BZ 57653 I found (and can reproduce with a debugger) an issue
where sockets could end up being closed twice if they were in the poller, the
connector is stopped and then closeSocket() was called.
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=1665653&r1=1665652&r2=1665653&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
19:19:32 2015
@@ -947,9 +947,7 @@ public class AprEndpoint extends Abstrac
// countDownConnection() in that case
Poller poller = this.poller;
if (poller != null) {
- if (!poller.close(socket)) {
- destroySocket(socket);
- }
+ poller.close(socket);
}
}
@@ -1420,9 +1418,24 @@ public class AprEndpoint extends Abstrac
} catch (InterruptedException e) {
// Ignore
}
+ // Close all sockets in the close queue
+ SocketInfo info = closeList.get();
+ while (info != null) {
+ // Make sure we aren't trying add the socket as well as close
it
+ addList.remove(info.socket);
+ // Make sure the socket isn't in the poller before we close it
+ removeFromPoller(info.socket);
+ // Poller isn't running at this point so use destroySocket()
+ // directly
+ destroySocket(info.socket);
+ info = closeList.get();
+ }
+ closeList.clear();
// Close all sockets in the add queue
- SocketInfo info = addList.get();
+ info = addList.get();
while (info != null) {
+ // Make sure the socket isn't in the poller before we close it
+ removeFromPoller(info.socket);
// Poller isn't running at this point so use destroySocket()
// directly
destroySocket(info.socket);
@@ -1516,17 +1529,10 @@ public class AprEndpoint extends Abstrac
}
- protected boolean close(long socket) {
- if (!pollerRunning) {
- return false;
- }
+ protected void close(long socket) {
synchronized (this) {
- if (!pollerRunning) {
- return false;
- }
closeList.add(socket, 0, 0);
this.notify();
- return true;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]