This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new 834be80 Attempt to fix APR crash on shutdown.
834be80 is described below
commit 834be80289bf95a9ef21d3cac323ddaa7b231304
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 11 12:58:52 2021 +0000
Attempt to fix APR crash on shutdown.
These crashes have been observed with the new BuildBot CI system. Local
testing indicates this fix addresses the issue but it might just be
changing the timing.
---
java/org/apache/tomcat/util/net/AprEndpoint.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java
b/java/org/apache/tomcat/util/net/AprEndpoint.java
index 9dda480..4445a97 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -714,11 +714,22 @@ public class AprEndpoint extends
AbstractEndpoint<Long,Long> implements SNICallB
log.warn(sm.getString("endpoint.err.attach",
Integer.valueOf(rv)));
return false;
}
- if (SSLSocket.handshake(socket) != 0) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("endpoint.err.handshake") + ":
" + SSL.getLastError());
+
+ // Need to make sure the socket doesn't get closed while the
+ // handshake is in progress as that could trigger a JVM crash.
+ // Like stopInternal(), use the blocking status write lock as a
+ // proxy for a lock on writing to the socket.
+ WriteLock wl = ((AprSocketWrapper)
socketWrapper).getBlockingStatusWriteLock();
+ wl.lock();
+ try {
+ if (SSLSocket.handshake(socket) != 0) {
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("endpoint.err.handshake") +
": " + SSL.getLastError());
+ }
+ return false;
}
- return false;
+ } finally {
+ wl.unlock();
}
if (negotiableProtocols.size() > 0) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]