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


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1891721 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/server/connection.c b/server/connection.c
index 1974537..b0093e1 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -139,18 +139,12 @@
     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 @@
     apr_socket_t *csd = ap_get_conn_socket(c);
 
     if (ap_start_lingering_close(c)) {
+        apr_socket_close(csd);
         return;
     }