This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 6f2f76d664c146276adebfdcf6847342ca903b08 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Jan 10 17:22:28 2022 +0000 Refactor Connector/Endpoint pause only stop new connections/requests --- java/org/apache/coyote/AbstractProtocol.java | 6 +----- java/org/apache/tomcat/util/net/AprEndpoint.java | 10 +--------- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 4 ++-- java/org/apache/tomcat/util/net/NioEndpoint.java | 6 +++--- webapps/docs/changelog.xml | 5 +++++ 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index 949dbc5..4f854b9 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -614,9 +614,7 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, endpoint.start(); monitorFuture = getUtilityExecutor().scheduleWithFixedDelay( () -> { - if (!isPaused()) { - startAsyncTimeout(); - } + startAsyncTimeout(); }, 0, 60, TimeUnit.SECONDS); } @@ -659,7 +657,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, getLog().info(sm.getString("abstractProtocolHandler.pause", getName())); } - stopAsyncTimeout(); endpoint.pause(); } @@ -676,7 +673,6 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, } endpoint.resume(); - startAsyncTimeout(); } diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index c3d65a6..01c2b77 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -1895,14 +1895,6 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB // Loop until we receive a shutdown command while (sendfileRunning) { - // Loop if endpoint is paused - while (sendfileRunning && paused) { - try { - Thread.sleep(pollTime / 1000); - } catch (InterruptedException e) { - // Ignore - } - } // Loop if poller is empty while (sendfileRunning && sendfileCount < 1 && addS.size() < 1) { // Reset maintain time. @@ -2142,7 +2134,7 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB socketWrapper = null; event = null; //return to cache - if (running && !paused && processorCache != null) { + if (running && processorCache != null) { processorCache.push(this); } } diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index 125261a..0ecac93 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -943,7 +943,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS if (getSocket().isOpen()) { getSocket().close(true); } - if (getEndpoint().running && !getEndpoint().paused) { + if (getEndpoint().running) { if (nioChannels == null || !nioChannels.push(getSocket())) { getSocket().free(); } @@ -1720,7 +1720,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS socketWrapper = null; event = null; //return to cache - if (running && !paused && processorCache != null) { + if (running && processorCache != null) { processorCache.push(this); } } diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 0131504..b5b0e50 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -718,7 +718,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> } } } - if (running && !paused && eventCache != null) { + if (running && eventCache != null) { pe.reset(); eventCache.push(pe); } @@ -1245,7 +1245,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> if (getSocket().isOpen()) { getSocket().close(true); } - if (getEndpoint().running && !getEndpoint().paused) { + if (getEndpoint().running) { if (nioChannels == null || !nioChannels.push(getSocket())) { getSocket().free(); } @@ -1753,7 +1753,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> socketWrapper = null; event = null; //return to cache - if (running && !paused && processorCache != null) { + if (running && processorCache != null) { processorCache.push(this); } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 004aea3..26aeced 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -158,6 +158,11 @@ <bug>65785</bug>: Perform additional validation of HTTP headers when using HTTP/2. (markt) </fix> + <fix> + When a Connector or Endpoint is paused, ensure that only new connections + and new requests on existing connections are stopped while allowing in + progress requests to run to completion. (markt) + </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