Author: remy.maucherat(a)jboss.com
Date: 2010-09-16 09:34:45 -0400 (Thu, 16 Sep 2010)
New Revision: 1551
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
Log:
- Production defaults for the endpoints. Hopefully ...
- Related to JBPAPP-4779: Drop socket when out of workers.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-09-16 13:32:46 UTC (rev
1550)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2010-09-16 13:34:45 UTC (rev
1551)
@@ -170,7 +170,7 @@
/**
* Maximum amount of worker threads.
*/
- protected int maxThreads = 200;
+ protected int maxThreads = 32 * Runtime.getRuntime().availableProcessors();
public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; }
public int getMaxThreads() { return maxThreads; }
@@ -186,7 +186,7 @@
/**
* Size of the socket poller.
*/
- protected int pollerSize = 8 * 1024;
+ protected int pollerSize = (OS.IS_WIN32 || OS.IS_WIN64) ? (8 * 1024) : (32 * 1024);
public void setPollerSize(int pollerSize) { this.pollerSize = pollerSize; }
public int getPollerSize() { return pollerSize; }
@@ -194,7 +194,7 @@
/**
* Size of the sendfile (= concurrent files which can be served).
*/
- protected int sendfileSize = 1 * 1024;
+ protected int sendfileSize = (OS.IS_WIN32 || OS.IS_WIN64) ? (1 * 1024) : (16 *
1024);
public void setSendfileSize(int sendfileSize) { this.sendfileSize = sendfileSize; }
public int getSendfileSize() { return sendfileSize; }
@@ -934,26 +934,6 @@
/**
- * Return a new worker thread, and block while to worker is available.
- */
- protected Worker getWorkerThread() {
- // Allocate a new worker thread
- Worker workerThread = createWorkerThread();
- while (workerThread == null) {
- try {
- synchronized (workers) {
- workers.wait();
- }
- } catch (InterruptedException e) {
- // Ignore
- }
- workerThread = createWorkerThread();
- }
- return workerThread;
- }
-
-
- /**
* Recycle the specified Processor so that it can be used again.
*
* @param workerThread The processor to be recycled
@@ -991,7 +971,12 @@
protected boolean processSocketWithOptions(long socket) {
try {
if (executor == null) {
- getWorkerThread().assignWithOptions(socket);
+ Worker worker = createWorkerThread();
+ if (worker != null) {
+ worker.assignWithOptions(socket);
+ } else {
+ return false;
+ }
} else {
executor.execute(new SocketWithOptionsProcessor(socket));
}
@@ -1011,7 +996,12 @@
protected boolean processSocket(long socket) {
try {
if (executor == null) {
- getWorkerThread().assign(socket);
+ Worker worker = createWorkerThread();
+ if (worker != null) {
+ worker.assign(socket);
+ } else {
+ return false;
+ }
} else {
executor.execute(new SocketProcessor(socket));
}
@@ -1031,7 +1021,12 @@
protected boolean processSocket(long socket, SocketStatus status) {
try {
if (executor == null) {
- getWorkerThread().assign(socket, status);
+ Worker worker = createWorkerThread();
+ if (worker != null) {
+ worker.assign(socket, status);
+ } else {
+ return false;
+ }
} else {
executor.execute(new SocketEventProcessor(socket, status));
}
Modified: trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2010-09-16 13:32:46 UTC (rev
1550)
+++ trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java 2010-09-16 13:34:45 UTC (rev
1551)
@@ -155,7 +155,7 @@
/**
* Maximum amount of worker threads.
*/
- protected int maxThreads = 200;
+ protected int maxThreads = 512 * Runtime.getRuntime().availableProcessors();
public void setMaxThreads(int maxThreads) { this.maxThreads = maxThreads; }
public int getMaxThreads() { return maxThreads; }
@@ -1205,26 +1205,6 @@
/**
- * Return a new worker thread, and block while to worker is available.
- */
- protected Worker getWorkerThread() {
- // Allocate a new worker thread
- Worker workerThread = createWorkerThread();
- while (workerThread == null) {
- try {
- synchronized (workers) {
- workers.wait();
- }
- } catch (InterruptedException e) {
- // Ignore
- }
- workerThread = createWorkerThread();
- }
- return workerThread;
- }
-
-
- /**
* Recycle the specified Processor so that it can be used again.
*
* @param workerThread The processor to be recycled
@@ -1244,7 +1224,12 @@
protected boolean processSocket(Socket socket) {
try {
if (executor == null) {
- getWorkerThread().assign(socket);
+ Worker worker = createWorkerThread();
+ if (worker != null) {
+ worker.assign(socket);
+ } else {
+ return false;
+ }
} else {
executor.execute(new SocketProcessor(socket));
}
@@ -1264,7 +1249,12 @@
protected boolean processSocket(Socket socket, SocketStatus status) {
try {
if (executor == null) {
- getWorkerThread().assign(socket, status);
+ Worker worker = createWorkerThread();
+ if (worker != null) {
+ worker.assign(socket, status);
+ } else {
+ return false;
+ }
} else {
executor.execute(new SocketEventProcessor(socket, status));
}