]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Quit registering *two* cleanups listening sockets prior to exec.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 31 Mar 2003 04:30:52 +0000 (04:30 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Mon, 31 Mar 2003 04:30:52 +0000 (04:30 +0000)
  We open them once, register a cleanup only once.

Submitted by: Jeff Trawick
Reviewed by: FirstBill, OtherBill

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@99131 13f79535-47bb-0310-9956-ffa450edef68

server/listen.c

index 4f410414a9ed1efbd46c90ef5ea1ccaf951e2500..0ce1143abc864497ba6c2a9b879b156fd1644bdd 100644 (file)
@@ -340,6 +340,8 @@ static int ap_listen_open(apr_pool_t *pool, apr_port_t port)
     ap_listen_rec *lr;
     ap_listen_rec *next;
     int num_open;
+    const char *userdata_key = "ap_listen_open";
+    void *data;
 
     /* Don't allocate a default listener.  If we need to listen to a
      * port, then the user needs to have a Listen directive in their
@@ -370,8 +372,17 @@ static int ap_listen_open(apr_pool_t *pool, apr_port_t port)
     }
     old_listeners = NULL;
 
-    apr_pool_cleanup_register(pool, NULL, apr_pool_cleanup_null,
-                              close_listeners_on_exec);
+    /* we come through here on both passes of the open logs phase
+     * only register the cleanup once... otherwise we try to close
+     * listening sockets twice when cleaning up prior to exec
+     */
+    apr_pool_userdata_get(&data, userdata_key, pool);
+    if (!data) {
+        apr_pool_userdata_set((const void *)1, userdata_key,
+                              apr_pool_cleanup_null, pool);
+        apr_pool_cleanup_register(pool, NULL, apr_pool_cleanup_null,
+                                  close_listeners_on_exec);
+    }
 
     return num_open ? 0 : -1;
 }