(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
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 3d81c5cd9e3836be806b651b0f81dc68f58fc4f4
Author: Mark Thomas 
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 b047a5490e..d6dfe75f5f 100644
--- a/java/org/apache/tomcat/util/net/AbstractEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AbstractEndpoint.java
@@ -1562,7 +1562,7 @@ public abstract class AbstractEndpoint {
 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 bbfd8dd695..3b5cf500a3 100644
--- a/java/org/apache/tomcat/util/net/Acceptor.java
+++ b/java/org/apache/tomcat/util/net/Acceptor.java
@@ -200,12 +200,20 @@ public class Acceptor 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 21b9f8acfb..0c8848bb98 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -210,7 +210,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint {
@@ -448,11 +448,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 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



(tomcat) 03/04: Refactor to specify acceptor stop wait time in ms rather than s

2024-04-19 Thread markt
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 
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 {
 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 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 {
@@ -437,11 +437,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint
 }
 if (running) {
 running = false;
-acceptor.stop(10);
+acceptor.stopMillis(1);
 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