From: William A. Rowe Jr Date: Wed, 20 Mar 2002 07:03:07 +0000 (+0000) Subject: Here's the patch that really sucks. old_listeners points to an array X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f1fdebb2d7b574095bc217521afc7481d4a1384;p=apache Here's the patch that really sucks. old_listeners points to an array of apr_socket objects already destroyed by their cleanups, and in any case they now live in invalid memory. Extend their lifetimes. This implies that the process pool grows on every restart for no good reason. One possible solution is to let the old pconf survive until the new pconf is alive. Another is to create the listeners in a subpool of process->pool, destroyed after the old_listeners are closed. Either which way, a better solution exists, but this closes the immediate bug. [How haven't we been segfaulting in unix on restarts before this patch, gurus?] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94048 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/listen.c b/server/listen.c index a5b4b0c14e..8e0a539dd4 100644 --- a/server/listen.c +++ b/server/listen.c @@ -307,9 +307,8 @@ static void alloc_listener(process_rec *process, char *addr, apr_port_t port) ap_listeners = new; } -static int ap_listen_open(process_rec *process, apr_port_t port) +static int ap_listen_open(apr_pool_t *pool, apr_port_t port) { - apr_pool_t *pconf = process->pconf; ap_listen_rec *lr; ap_listen_rec *next; int num_open; @@ -324,7 +323,7 @@ static int ap_listen_open(process_rec *process, apr_port_t port) ++num_open; } else { - if (make_sock(pconf, lr) == APR_SUCCESS) { + if (make_sock(pool, lr) == APR_SUCCESS) { ++num_open; lr->active = 1; } @@ -343,7 +342,7 @@ static int ap_listen_open(process_rec *process, apr_port_t port) } old_listeners = NULL; - apr_pool_cleanup_register(pconf, NULL, apr_pool_cleanup_null, + apr_pool_cleanup_register(pool, NULL, apr_pool_cleanup_null, close_listeners_on_exec); return num_open ? 0 : -1; @@ -354,7 +353,7 @@ int ap_setup_listeners(server_rec *s) ap_listen_rec *lr; int num_listeners = 0; - if (ap_listen_open(s->process, s->port)) { + if (ap_listen_open(s->process->pool, s->port)) { return 0; }