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 c20f672  Improve error handling
c20f672 is described below

commit c20f6722ca66ea190b1c699f5beba78378bf2265
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Nov 10 18:15:39 2021 +0000

    Improve error handling
    
    I'm not entirely convinced this code path is possible but as we are
    still seeing JVM crashes in Buildbot, the check seems reasonable.
---
 java/org/apache/tomcat/util/net/AprEndpoint.java        | 3 +++
 java/org/apache/tomcat/util/net/LocalStrings.properties | 1 +
 webapps/docs/changelog.xml                              | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java 
b/java/org/apache/tomcat/util/net/AprEndpoint.java
index c09aaa2..0413434 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -858,6 +858,9 @@ public class AprEndpoint extends AbstractEndpoint<Long> 
implements SNICallBack {
                         // Accept the next incoming connection from the server
                         // socket
                         socket = Socket.accept(serverSock);
+                        if (socket == 0) {
+                            throw new 
IOException(sm.getString("endpoint.err.accept", getName()));
+                        }
                         if (log.isDebugEnabled()) {
                             long sa = Address.get(Socket.APR_REMOTE, socket);
                             Sockaddr addr = Address.getInfo(sa);
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties 
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index ad190eb..eeeeede 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -76,6 +76,7 @@ endpoint.debug.unlock.fail=Caught exception trying to unlock 
accept on port [{0}
 endpoint.debug.unlock.localFail=Unable to determine local address for [{0}]
 endpoint.debug.unlock.localNone=Failed to unlock acceptor for [{0}] because 
the local address was not available
 endpoint.duplicateSslHostName=Multiple SSLHostConfig elements were provided 
for the host name [{0}]. Host names must be unique.
+endpoint.err.accept=Failed to accept socket for end point [{0}]
 endpoint.err.attach=Failed to attach SSLContext to socket - error [{0}]
 endpoint.err.close=Caught exception trying to close socket
 endpoint.err.handshake=Handshake failed
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5b9b203..d3c11e5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -141,6 +141,10 @@
         Improve error handling if APR/Native fails to attach TLS capabilities 
to
         a TLS enabled client connection. (markt)
       </fix>
+      <fix>
+        Improve error handling if APR/Native fails to accept an incoming
+        connection. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="WebSocket">

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

Reply via email to