Only need to wait a single pollTime, not one pollTime for each poller.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 27 Jul 2010 20:27:16 +0000 (20:27 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 27 Jul 2010 20:27:16 +0000 (20:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@979852 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/AprEndpoint.java

index 822347a..c96edc1 100644 (file)
@@ -663,6 +663,16 @@ public class AprEndpoint extends AbstractEndpoint {
         if (running) {
             running = false;
             unlockAccept();
+            // Wait for polltime 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.wait(pollTime);
+                }
+            } catch (InterruptedException e) {
+                // Ignore
+            }
             for (int i = 0; i < pollers.length; i++) {
                 pollers[i].destroy();
             }
@@ -959,16 +969,6 @@ public class AprEndpoint extends AbstractEndpoint {
          * Destroy the poller.
          */
         protected void destroy() {
-            // Wait for polltime 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.wait(pollTime);
-                }
-            } catch (InterruptedException e) {
-                // Ignore
-            }
             // Close all sockets in the add queue
             for (int i = 0; i < addCount; i++) {
                 if (comet) {
@@ -1218,16 +1218,6 @@ public class AprEndpoint extends AbstractEndpoint {
          * Destroy the poller.
          */
         protected void destroy() {
-            // Wait for polltime 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.wait(pollTime);
-                }
-            } catch (InterruptedException e) {
-                // Ignore
-            }
             // Close any socket remaining in the add queue
             addCount = 0;
             for (int i = (addS.size() - 1); i >= 0; i--) {