Author: markt
Date: Mon Sep 30 19:34:17 2013
New Revision: 1527737

URL: http://svn.apache.org/r1527737
Log:
Refactor the remove list in the Poller to be a close list. The poller
now removes the socket if it is in the Poller then destroys it. Note the
socket is always destroyed whether it is found in the Poller or not.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1527730

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1527737&r1=1527736&r2=1527737&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Mon 
Sep 30 19:34:17 2013
@@ -899,9 +899,10 @@ public class AprEndpoint extends Abstrac
         // countDownConnection() in that case
         Poller poller = this.poller;
         if (poller != null) {
-            poller.remove(socket);
+            if (!poller.close(socket)) {
+                destroySocketInternal(socket, true);
+            }
         }
-        destroySocketInternal(socket, running);
     }
 
     private void destroySocketInternal(long socket, boolean doIt) {
@@ -1281,9 +1282,9 @@ public class AprEndpoint extends Abstrac
 
         
         /**
-         * List of sockets to be removed from the poller.
+         * List of sockets to be closed.
          */
-        private SocketList removeList = null;
+        private SocketList closeList = null;
 
 
         /**
@@ -1360,7 +1361,7 @@ public class AprEndpoint extends Abstrac
             desc = new long[actualPollerSize * 2];
             connectionCount = 0;
             addList = new SocketList(defaultPollerSize);
-            removeList = new SocketList(defaultPollerSize);
+            closeList = new SocketList(defaultPollerSize);
         }
 
 
@@ -1497,9 +1498,16 @@ public class AprEndpoint extends Abstrac
         }
 
 
-        protected void remove(long socket) {
+        protected boolean close(long socket) {
+            if (!pollerRunning) {
+                return false;
+            }
             synchronized (this) {
-                removeList.add(socket, 0, 0);
+                if (!pollerRunning) {
+                    return false;
+                }
+                closeList.add(socket, 0, 0);
+                return true;
             }
         }
 
@@ -1548,7 +1556,7 @@ public class AprEndpoint extends Abstrac
                         Long.valueOf(socket)).isComet();
                 if (!comet || (comet && !processSocket(
                         socket, SocketStatus.TIMEOUT))) {
-                    destroySocket(socket);
+                    destroySocketInternal(socket, true);
                 }
                 socket = timeouts.check(date);
             }
@@ -1583,7 +1591,7 @@ public class AprEndpoint extends Abstrac
 
             int maintain = 0;
             SocketList localAddList = new SocketList(getMaxConnections());
-            SocketList localRemoveList = new SocketList(getMaxConnections());
+            SocketList localCloseList = new SocketList(getMaxConnections());
 
             // Loop until we receive a shutdown command
             while (pollerRunning) {
@@ -1623,15 +1631,15 @@ public class AprEndpoint extends Abstrac
                 try {
                     // Duplicate the add and remove lists so that the syncs are
                     // minimised
-                    if (removeList.size() > 0) {
+                    if (closeList.size() > 0) {
                         synchronized (this) {
                             // Duplicate to another list, so that the syncing 
is
                             // minimal
-                            removeList.duplicate(localRemoveList);
-                            removeList.clear();
+                            closeList.duplicate(localCloseList);
+                            closeList.clear();
                         }
                     } else {
-                        localRemoveList.clear();
+                        localCloseList.clear();
                     }
                     if (addList.size() > 0) {
                         synchronized (this) {
@@ -1645,12 +1653,13 @@ public class AprEndpoint extends Abstrac
                     }
 
                     // Remove sockets
-                    if (localRemoveList.size() > 0) {
-                        SocketInfo info = localRemoveList.get();
+                    if (localCloseList.size() > 0) {
+                        SocketInfo info = localCloseList.get();
                         while (info != null) {
                             localAddList.remove(info.socket);
                             removeFromPoller(info.socket);
-                            info = localRemoveList.get();
+                            destroySocketInternal(info.socket, true);
+                            info = localCloseList.get();
                         }
                     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to