Author: jfrederic.clere(a)jboss.com
Date: 2010-08-11 13:15:11 -0400 (Wed, 11 Aug 2010)
New Revision: 1526
Modified:
branches/2.1.x/java/org/apache/tomcat/util/net/JIoEndpoint.java
Log:
Try to reduce the JBPAPP-4779.
Modified: branches/2.1.x/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/net/JIoEndpoint.java 2010-08-11 17:00:08
UTC (rev 1525)
+++ branches/2.1.x/java/org/apache/tomcat/util/net/JIoEndpoint.java 2010-08-11 17:15:11
UTC (rev 1526)
@@ -163,6 +163,10 @@
public void setThreadPriority(int threadPriority) { this.threadPriority =
threadPriority; }
public int getThreadPriority() { return threadPriority; }
+ /*
+ * wait for free worker when MaxThreads is reached.
+ */
+ protected boolean WAITFORWORKER =
Boolean.valueOf(System.getProperty("org.apache.tomcat.util.net.WAITFORWORKER",
"false")).booleanValue();
/**
* Server socket port.
@@ -700,7 +704,7 @@
protected Worker getWorkerThread() {
// Allocate a new worker thread
Worker workerThread = createWorkerThread();
- while (workerThread == null) {
+ while (workerThread == null && WAITFORWORKER) {
try {
synchronized (workers) {
workers.wait();
@@ -734,7 +738,11 @@
protected boolean processSocket(Socket socket) {
try {
if (executor == null) {
- getWorkerThread().assign(socket);
+ Worker worker = getWorkerThread();
+ if (worker != null)
+ worker.assign(socket);
+ else
+ return false;
} else {
executor.execute(new SocketProcessor(socket));
}
Show replies by date