]> granicus.if.org Git - apache/commitdiff
Now that we test ownership of the listeners in listen.c, -k "start"
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 14 Mar 2002 04:12:12 +0000 (04:12 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 14 Mar 2002 04:12:12 +0000 (04:12 +0000)
  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

index 17c69cfd57293f02c363453b5cca2cb8f50697e4..8d2710cf4200fec0d6e061608813f1a6bcf39708 100644 (file)
@@ -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;
 }