You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/09/30 21:25:18 UTC

svn commit: r1527730 - /tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Author: markt
Date: Mon Sep 30 19:25:18 2013
New Revision: 1527730

URL: http://svn.apache.org/r1527730
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/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=1527730&r1=1527729&r2=1527730&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Mon Sep 30 19:25:18 2013
@@ -907,9 +907,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) {
@@ -1289,9 +1290,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;
 
 
         /**
@@ -1368,7 +1369,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);
         }
 
 
@@ -1505,9 +1506,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;
             }
         }
 
@@ -1556,7 +1564,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);
             }
@@ -1591,7 +1599,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) {
@@ -1631,15 +1639,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) {
@@ -1653,12 +1661,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org