You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/11/23 19:12:04 UTC
[tomcat] branch 8.5.x updated: Stop sendfile before closing sockets
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 95932ab Stop sendfile before closing sockets
95932ab is described below
commit 95932abe5ec57402ac9e6cb427ce835c6c55720e
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Nov 23 19:10:09 2021 +0000
Stop sendfile before closing sockets
---
java/org/apache/tomcat/util/net/AprEndpoint.java | 58 +++++++++++++-----------
1 file changed, 31 insertions(+), 27 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java
index 52bbd31..b25398b 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -532,6 +532,34 @@ public class AprEndpoint extends AbstractEndpoint<Long> implements SNICallBack {
// Ignore
}
+ if (getUseSendfile()) {
+ try {
+ sendfile.stop();
+
+ // Wait for the sendfile thread to exit, otherwise parallel
+ // destruction of sockets which are still in the poller can cause
+ // problems.
+ waitMillis = 0;
+ try {
+ while (sendfile.sendfileThread.isAlive() && waitMillis < 10000) {
+ waitMillis++;
+ Thread.sleep(1);
+ }
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+
+ if (sendfile.sendfileThread.isAlive()) {
+ log.warn(sm.getString("endpoint.sendfileThreadStop"));
+ }
+
+ sendfile.destroy();
+ } catch (Exception e) {
+ // Ignore
+ }
+ sendfile = null;
+ }
+
// Close the SocketWrapper for each open connection - this should
// trigger a IOException when the app (or container) tries to write.
// Use the blocking status write lock as a proxy for a lock on
@@ -563,34 +591,10 @@ public class AprEndpoint extends AbstractEndpoint<Long> implements SNICallBack {
}
poller = null;
connections.clear();
- if (getUseSendfile()) {
- try {
- sendfile.stop();
-
- // Wait for the sendfile thread to exit, otherwise parallel
- // destruction of sockets which are still in the poller can cause
- // problems.
- waitMillis = 0;
- try {
- while (sendfile.sendfileThread.isAlive() && waitMillis < 10000) {
- waitMillis++;
- Thread.sleep(1);
- }
- } catch (InterruptedException e) {
- // Ignore
- }
-
- if (sendfile.sendfileThread.isAlive()) {
- log.warn(sm.getString("endpoint.sendfileThreadStop"));
- }
-
- sendfile.destroy();
- } catch (Exception e) {
- // Ignore
- }
- sendfile = null;
+ if (processorCache != null) {
+ processorCache.clear();
+ processorCache = null;
}
- processorCache.clear();
}
shutdownExecutor();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org