This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 3f2df25 Avoid most of the thread pool use during NIO2 socket accept 3f2df25 is described below commit 3f2df25b8e5a7a7be595437a2fcea8040ed71fd4 Author: remm <r...@apache.org> AuthorDate: Thu Oct 29 22:26:09 2020 +0100 Avoid most of the thread pool use during NIO2 socket accept When maxConnections is not -1, the socket accept of NIO2 competes with the other request execution activities. This can be avoided when it is known that it will not block. Patch submitted by Anil Gursel. --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 8 ++++++++ webapps/docs/changelog.xml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index 284f342..15873ec 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -434,6 +434,14 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS if (isRunning() && !isPaused()) { if (getMaxConnections() == -1) { serverSock.accept(null, this); + } else if (getConnectionCount() < getMaxConnections()) { + try { + // This will not block + countUpOrAwaitConnection(); + } catch (InterruptedException e) { + // Ignore + } + serverSock.accept(null, this); } else { // Accept again on a new thread since countUpOrAwaitConnection may block getExecutor().execute(this); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 8f86c9c..8d64420 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -116,6 +116,10 @@ Provide messages for some <code>SocketTimeoutException</code> instances that did not have one. (markt) </add> + <fix> + Avoid most of the thread pool use during NIO2 socket accept. Patch + submitted by Anil Gursel. (remm) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org