You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/10/29 21:26:50 UTC
[tomcat] branch master updated: Avoid most of the thread pool use
during NIO2 socket accept
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 7444f1e Avoid most of the thread pool use during NIO2 socket accept
7444f1e is described below
commit 7444f1e13b091e0c140cf4959c4530e84ef67fdd
Author: remm <re...@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 1d218a5..7bd882e 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -422,6 +422,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 68031ff..deebf81 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org