httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r239711 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c
Date Wed, 24 Aug 2005 16:58:14 GMT
Author: colm
Date: Wed Aug 24 09:58:11 2005
New Revision: 239711

URL: http://svn.apache.org/viewcvs?rev=239711&view=rev
Log:

Implement "de-listening" for graceful restarts with the prefork MPM. With this
change;

  1.) httpd -k graceful sends SIGUSR1 to the parent pid, which in turn
      sends SIGUSR1 to all of the active children,

  2.) Active children each close their copy of listener fd's.

This means that the listening sockets are freed for re-use. In the ordinary
case, this makes no difference. However if for example admin changes "Listen
80" to "Listen 81" in the config, this rev makes port 80 immediately available
(no waiting for the graceful children to die).


Modified:
    httpd/httpd/trunk/server/mpm/prefork/prefork.c

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=239711&r1=239710&r2=239711&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Wed Aug 24 09:58:11 2005
@@ -331,6 +331,11 @@
     clean_child_exit(0);
 }
 
+static void stop_listening(int sig)
+{
+    ap_close_listeners();
+}
+
 /* volatile just in case */
 static int volatile shutdown_pending;
 static int volatile restart_pending;
@@ -715,10 +720,10 @@
          */
         apr_signal(SIGHUP, just_die);
         apr_signal(SIGTERM, just_die);
-        /* The child process doesn't do anything for AP_SIG_GRACEFUL.  
-         * Instead, the pod is used for signalling graceful restart.
+        /* The child process just closes listeners on AP_SIG_GRACEFUL.  
+         * The pod is used for signalling the graceful restart.
          */
-        apr_signal(AP_SIG_GRACEFUL, SIG_IGN);
+        apr_signal(AP_SIG_GRACEFUL, stop_listening);
         child_main(slot);
     }
 
@@ -1096,6 +1101,7 @@
 
     /* we've been told to restart */
     apr_signal(SIGHUP, SIG_IGN);
+    apr_signal(AP_SIG_GRACEFUL, SIG_IGN);
     if (one_process) {
         /* not worth thinking about */
         return 1;
@@ -1123,6 +1129,14 @@
         for (index = 0; index < ap_daemons_limit; ++index) {
             if (ap_scoreboard_image->servers[index][0].status != SERVER_DEAD) {
                 ap_scoreboard_image->servers[index][0].status = SERVER_GRACEFUL;
+                /* Ask each child to close its listeners.
+                 *
+                 * NOTE: we use the scoreboard, because if we send SIGUSR1 
+                 * to every process in the group, this may include CGI's, 
+                 * piped loggers, etc. They almost certainly won't handle 
+                 * it gracefully. 
+                 */
+                kill(ap_scoreboard_image->parent[index].pid, AP_SIG_GRACEFUL);
             }
         }
     }



Mime
View raw message