You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2021/07/22 15:33:19 UTC

svn commit: r1891721 - /httpd/httpd/trunk/server/connection.c

Author: ylavic
Date: Thu Jul 22 15:33:19 2021
New Revision: 1891721

URL: http://svn.apache.org/viewvc?rev=1891721&view=rev
Log:
core: don't close the socket when failing in ap_start_lingering_close().

* server/connection.c (ap_start_lingering_close): Don't apr_socket_close().

* server/connection.c (ap_lingering_close): Do apr_socket_close() on
  ap_start_lingering_close() failure.

On failure ap_start_lingering_close() did not consistently close the socket,
so the caller had to call apr_socket_close() too with possible/unreliable
EBADF.  The only upstream callers of ap_start_lingering_close() are MPM event
and ap_start_lingering_close(), but any third-party user has this issue so the
change should't break anyone.

Follow up to r1891716.
Github: #208

Modified:
    httpd/httpd/trunk/server/connection.c

Modified: httpd/httpd/trunk/server/connection.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/connection.c?rev=1891721&r1=1891720&r2=1891721&view=diff
==============================================================================
--- httpd/httpd/trunk/server/connection.c (original)
+++ httpd/httpd/trunk/server/connection.c Thu Jul 22 15:33:19 2021
@@ -139,18 +139,12 @@ AP_DECLARE(int) ap_start_lingering_close
     ap_flush_conn(c);
 
 #ifdef NO_LINGCLOSE
-    apr_socket_close(csd);
     return 1;
 #else
     /* Shut down the socket for write, which will send a FIN
      * to the peer.
      */
-    if (c->aborted
-            || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) {
-        apr_socket_close(csd);
-        return 1;
-    }
-    return 0;
+    return (c->aborted || apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE));
 #endif
 }
 
@@ -162,6 +156,7 @@ AP_DECLARE(void) ap_lingering_close(conn
     apr_socket_t *csd = ap_get_conn_socket(c);
 
     if (ap_start_lingering_close(c)) {
+        apr_socket_close(csd);
         return;
     }