From: Justin Erenkrantz Date: Sat, 8 Dec 2001 01:38:05 +0000 (+0000) Subject: Fix segfault when restarting worker MPM. We can not examine the POD as X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88cf0471f86ffd27b802278c57c19868c1e4bfff;p=apache Fix segfault when restarting worker MPM. We can not examine the POD as a normal listener. There was an additional bug than what Ian submitted to fix listen.c (i.e. check sa for null): make_pipe_of_death does not zero out lr->bind_addr (since it uses apr_palloc). So, on Solaris, the first time through, bind_addr was probably 0, but the second time, not (pools!). (This caused Aaron's analysis that the patch worked the first time, but not the second time.) Submitted by: Ian Holsman Reviewed by: Justin Erenkrantz, Aaron Bannert git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92387 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 366b3833ca..605f145ed2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.30-dev + *) Fix segfault when worker MPM receives SIGHUP. + [Ian Holsman, Aaron Bannert, Justin Erenkrantz] + *) Fix bug that could potentially prevent the perchild MPM from working with more than one vhost/uid. [Aaron Bannert] diff --git a/STATUS b/STATUS index 7ea6afcd7f..23e54ec42d 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2001/12/07 18:10:25 $] +Last modified at [$Date: 2001/12/08 01:38:04 $] Release: @@ -92,12 +92,6 @@ RELEASE SHOWSTOPPERS: any) to segfault on AIX and can probably cause load or other errors on some other platforms. - * Sending httpd a SIGHUP with worker MPM causes a segfault - when we started as root and switch to a different user. - Aaron Says: I've only been able to reproduce this on - Solaris, works fine for Linux. Also, it appears - to be happening in the parent. - RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP: * There is increasing demand from module writers for an API diff --git a/server/listen.c b/server/listen.c index a8a5ab575b..4f16276dfb 100644 --- a/server/listen.c +++ b/server/listen.c @@ -237,15 +237,18 @@ static void alloc_listener(process_rec *process, char *addr, apr_port_t port) /* see if we've got an old listener for this address:port */ for (walk = &old_listeners; *walk; walk = &(*walk)->next) { sa = (*walk)->bind_addr; - apr_sockaddr_port_get(&oldport, sa); - apr_sockaddr_ip_get(&oldaddr, sa); - if (!strcmp(oldaddr, addr) && port == oldport) { - /* re-use existing record */ - new = *walk; - *walk = new->next; - new->next = ap_listeners; - ap_listeners = new; - return; + /* Some listeners are not real so they will not have a bind_addr. */ + if (sa) { + apr_sockaddr_port_get(&oldport, sa); + apr_sockaddr_ip_get(&oldaddr, sa); + if (!strcmp(oldaddr, addr) && port == oldport) { + /* re-use existing record */ + new = *walk; + *walk = new->next; + new->next = ap_listeners; + ap_listeners = new; + return; + } } } diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 339315d48a..69d1f8a61e 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -1269,6 +1269,8 @@ static void make_pipe_of_death(int *num_listeners, apr_pool_t *p) lr->sd = sd; lr->active = 1; lr->accept_func = check_pipe_of_death; + /* We are not bound to a real address. So, indicate that. */ + lr->bind_addr = 0; lr->next = ap_listeners; ap_listeners = lr; (*num_listeners)++;