This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ba98642273f1ce9a81857506dffb6dc370d7d2f9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 19 18:04:36 2024 +0100

    Refactor to specify acceptor stop wait time in ms rather than s
---
 java/org/apache/tomcat/util/net/AbstractEndpoint.java |  2 +-
 java/org/apache/tomcat/util/net/Acceptor.java         | 12 ++++++++++--
 java/org/apache/tomcat/util/net/Nio2Endpoint.java     |  6 +++---
 java/org/apache/tomcat/util/net/NioEndpoint.java      |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/AbstractEndpoint.java 
b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
index 460e7543f5..03a12d1959 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1493,7 +1493,7 @@ public abstract class AbstractEndpoint<S,U> {
     public final void closeServerSocketGraceful() {
         if (bindState == BindState.BOUND_ON_START) {
             // Stop accepting new connections
-            acceptor.stop(-1);
+            acceptor.stopMillis(-1);
             // Release locks that may be preventing the acceptor from stopping
             releaseConnectionLatch();
             unlockAccept();
diff --git a/java/org/apache/tomcat/util/net/Acceptor.java 
b/java/org/apache/tomcat/util/net/Acceptor.java
index b1083b292a..d8deb8cb26 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -171,12 +171,20 @@ public class Acceptor<U> implements Runnable {
      *
      * @param waitSeconds The time to wait in seconds. Use a value less than
      *                    zero for no wait.
+     *
+     * @deprecated Unused. Will be remove in Tomcat 11 onwards.
      */
+    @Deprecated
     public void stop(int waitSeconds) {
+        stopMillis(waitSeconds * 1000);
+    }
+
+
+    public void stopMillis(int waitMilliseconds) {
         stopCalled = true;
-        if (waitSeconds > 0) {
+        if (waitMilliseconds > 0) {
             try {
-                if (!stopLatch.await(waitSeconds, TimeUnit.SECONDS)) {
+                if (!stopLatch.await(waitMilliseconds, TimeUnit.MILLISECONDS)) 
{
                    log.warn(sm.getString("acceptor.stop.fail", 
getThreadName()));
                 }
             } catch (InterruptedException e) {
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java 
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 5bbc3a11f8..0c3cbad675 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -199,7 +199,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
         }
         if (running) {
             running = false;
-            acceptor.stop(10);
+            acceptor.stopMillis(10);
             // Use the executor to avoid binding the main thread if something 
bad
             // occurs and unbind will also wait for a bit for it to complete
             getExecutor().execute(() -> {
@@ -437,11 +437,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
         /**
          * Signals the Acceptor to stop.
          *
-         * @param waitSeconds Ignored for NIO2.
+         * @param waitMilliseconds Ignored for NIO2.
          *
          */
         @Override
-        public void stop(int waitSeconds) {
+        public void stopMillis(int waitMilliseconds) {
             acceptor.state = AcceptorState.ENDED;
         }
 
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 508682c8fc..c53164e256 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -296,7 +296,7 @@ public class NioEndpoint extends 
AbstractJsseEndpoint<NioChannel,SocketChannel>
         }
         if (running) {
             running = false;
-            acceptor.stop(10);
+            acceptor.stopMillis(10000);
             if (poller != null) {
                 poller.destroy();
                 poller = null;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to