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
The following commit(s) were added to refs/heads/9.0.x by this push: new 3cbfa18 Refactor the Acceptor to make the stop on wait optional/configurable 3cbfa18 is described below commit 3cbfa18d55122afdefe36590d7f67e4d4b40d5ed Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Nov 17 17:33:51 2020 +0000 Refactor the Acceptor to make the stop on wait optional/configurable This is some preparatory work towards a fix for BZ 64080. https://bz.apache.org/bugzilla/show_bug.cgi?id=64080 I need to be able to signal the Acceptor to stop without having to wait for the stop to complete. --- java/org/apache/tomcat/util/net/Acceptor.java | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Acceptor.java b/java/org/apache/tomcat/util/net/Acceptor.java index 2927b6f..ff810e9 100644 --- a/java/org/apache/tomcat/util/net/Acceptor.java +++ b/java/org/apache/tomcat/util/net/Acceptor.java @@ -156,14 +156,38 @@ public class Acceptor<U> implements Runnable { } + /** + * Signals the Acceptor to stop, waiting at most 10 seconds for the stop to + * complete before returning. If the stop does not complete in that time a + * warning will be logged. + * + * @deprecated This method will be removed in Tomcat 10.1.x onwards. + * Use {@link #stop(int)} instead. + */ + @Deprecated public void stop() { + stop(10); + } + + + /** + * Signals the Acceptor to stop, optionally waiting for that stop process + * to complete before returning. If a wait is requested and the stop does + * not complete in that time a warning will be logged. + * + * @param waitSeconds The time to wait in seconds. Use a value less than + * zero for no wait. + */ + public void stop(int waitSeconds) { stopCalled = true; - try { - if (!stopLatch.await(10, TimeUnit.SECONDS)) { - log.warn(sm.getString("acceptor.stop.fail", getThreadName())); + if (waitSeconds > 0) { + try { + if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) { + log.warn(sm.getString("acceptor.stop.fail", getThreadName())); + } + } catch (InterruptedException e) { + log.warn(sm.getString("acceptor.stop.interrupted", getThreadName()), e); } - } catch (InterruptedException e) { - log.warn(sm.getString("acceptor.stop.interrupted", getThreadName()), e); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org