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:10:46 UTC
[tomcat] branch 9.0.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 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 8d5ec7a Stop sendfile before closing sockets
8d5ec7a is described below
commit 8d5ec7ad2a8f2e919f693a9830228de61b99d6b9
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 | 55 ++++++++++++------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java
index dde0e0c..17e7fe4 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -576,6 +576,34 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
// 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
@@ -605,33 +633,6 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
}
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;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org