From 6d0a9307b33d1f46efd799ce5a8d41edabd1d6da Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Thu, 14 Mar 2002 04:12:12 +0000 Subject: [PATCH] Now that we test ownership of the listeners in listen.c, -k "start" can no longer hang on to the listeners after it checks that they are free. Also, we cannot be checking listeners if we are using -k "config" to alter the service config, since the service might be running as we try this, and we cannot check the listeners in -k "restart", since we are pretty certain they are owned by the running service we are about to try restarting.. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93926 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/winnt/mpm_winnt.c | 38 +++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 17c69cfd57..8d2710cf42 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -2209,6 +2209,13 @@ static int winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *pt } if (!strcasecmp(signal_arg, "start")) { + ap_listen_rec *lr; + + /* Close the listening sockets. */ + for (lr = ap_listeners; lr; lr = lr->next) { + apr_socket_close(lr->sd); + lr->active = 0; + } rv = mpm_service_start(ptemp, inst_argc, inst_argv); exit (rv); } @@ -2308,17 +2315,30 @@ static int winnt_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, s pconf = p; ap_server_conf = s; - if ((parent_pid == my_pid) || one_process) { - if (ap_setup_listeners(ap_server_conf) < 1) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT|APLOG_STARTUP, 0, - NULL, "no listening sockets available, shutting down"); - return DONE; - } + if (parent_pid != my_pid) { + return OK; + } - if (!set_listeners_noninheritable(pconf)) { - return 1; - } + /* We cannot initialize our listeners if we are restarting + * (the parent process already has glomed on to them) + * nor should we do so for service reconfiguration + * (since the service may already be running.) + */ + if (!strcasecmp(signal_arg, "restart") + || !strcasecmp(signal_arg, "config")) { + return OK; + } + + if (ap_setup_listeners(ap_server_conf) < 1) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT|APLOG_STARTUP, 0, + NULL, "no listening sockets available, shutting down"); + return DONE; + } + + if (!set_listeners_noninheritable(pconf)) { + return 1; } + return OK; } -- 2.40.0