Author: remy.maucherat(a)jboss.com
Date: 2013-11-29 10:13:32 -0500 (Fri, 29 Nov 2013)
New Revision: 2313
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/JIoEndpoint.java
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
Log:
BZ 1035787: Submitted by Ladislav Thon, once paused (and not resumed) the connector would
leak some threads. Visible during testing management mostly.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java 2013-11-28
15:02:26 UTC (rev 2312)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java 2013-11-29
15:13:32 UTC (rev 2313)
@@ -1068,13 +1068,16 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Ignore
}
}
+ if (!running) {
+ break;
+ }
if (reverseConnection) {
if (poller.getConnectionCount() < (maxThreads / 5)) {
@@ -1677,7 +1680,7 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -1685,7 +1688,7 @@
}
}
// Check timeouts for suspended connections if the poller is empty
- while (connectionCount < 1 && addList.size() < 1) {
+ while (running && connectionCount < 1 &&
addList.size() < 1) {
// Reset maintain time.
try {
if (soTimeout > 0 && running) {
@@ -1700,6 +1703,9 @@
CoyoteLogger.UTIL_LOGGER.errorProcessingSocketTimeout(t);
}
}
+ if (!running) {
+ break;
+ }
try {
// Add sockets which are waiting to the poller
@@ -2259,7 +2265,7 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -2267,7 +2273,7 @@
}
}
// Loop if poller is empty
- while (sendfileCount < 1 && addS.size() < 1) {
+ while (running && sendfileCount < 1 && addS.size()
< 1) {
// Reset maintain time.
maintainTime = 0;
try {
@@ -2278,6 +2284,9 @@
// Ignore
}
}
+ if (!running) {
+ break;
+ }
try {
// Add socket to the poller
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/JIoEndpoint.java 2013-11-28
15:02:26 UTC (rev 2312)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/JIoEndpoint.java 2013-11-29
15:13:32 UTC (rev 2313)
@@ -296,13 +296,16 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Ignore
}
}
+ if (!running) {
+ break;
+ }
// Accept the next incoming connection from the server socket
try {
@@ -714,7 +717,7 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -722,7 +725,7 @@
}
}
// Check timeouts for suspended connections if the poller is empty
- while (connectionCount < 1 && addList.size() < 1) {
+ while (running && connectionCount < 1 &&
addList.size() < 1) {
// Reset maintain time.
try {
if (soTimeout > 0 && running) {
@@ -737,6 +740,9 @@
CoyoteLogger.UTIL_LOGGER.errorProcessingSocketTimeout(t);
}
}
+ if (!running) {
+ break;
+ }
try {
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2013-11-28
15:02:26 UTC (rev 2312)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2013-11-29
15:13:32 UTC (rev 2313)
@@ -542,13 +542,16 @@
// Loop until we receive a shutdown command
while (running) {
// Loop if end point is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Ignore
}
}
+ if (!running) {
+ break;
+ }
try {
// Accept the next incoming connection from the server
@@ -963,7 +966,7 @@
public void run() {
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -971,7 +974,7 @@
}
}
- while (this.channelList.size() < 1 && running) {
+ while (running && this.channelList.size() < 1 && running) {
synchronized (this.mutex) {
try {
this.mutex.wait(10000);
@@ -981,7 +984,7 @@
}
}
- while (this.channelList.size() > 0 && running) {
+ while (running && this.channelList.size() > 0 && running) {
maintain();
try {
Thread.sleep(5000);
@@ -1385,7 +1388,7 @@
while (running) {
// Loop if endpoint is paused
- while (paused) {
+ while (running && paused) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Show replies by date