This goes a ways towards getting SIGWINCH and SIGHUP to do something.

I'm pretty sure that Ryan disagrees with the path I took for SIGHUP,
which is to kill everybody we can with the pod (since that is the most
clean and reliable mechanism we have) and let
ap_reclaim_child_processes() handle the stragglers.

With this patch, SIGWINCH and SIGHUP basically work for me on a
particular machine :)  

a couple of "issues" I have noted:

. occasionally after restart we get more server processes than we
  need, and this then gets lowered to the number specified by
  MaxSpareServers 

. cgid [sometimes, usually? can't remember] doesn't go away cleanly on
  SIGHUP; I guess there is a requirement on the MPM w.r.t. SIGHUP that
  I don't understand

There are surely other issues.  I didn't understand Ryan's changes to
prefork signalling when he added the pod (other than the fact that
SIGHUP and SIGWINCH no longer caused a restart) so I don't feel to bad
about still being in the dark.  

I don't currently know how to proceed further with this until there is
some agreement about how a non-graceful restart will be implemented.

Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.180
diff -u -r1.180 prefork.c
--- server/mpm/prefork/prefork.c        2001/06/12 14:04:12     1.180
+++ server/mpm/prefork/prefork.c        2001/06/13 14:13:22
@@ -413,11 +413,9 @@
        return;
     }
     restart_pending = 1;
-#if 0
     if ((is_graceful = (sig == SIGWINCH))) {
         apr_pool_cleanup_kill(pconf, NULL, ap_cleanup_scoreboard);
     }
-#endif
 }
 
 static void set_signals(void)
@@ -480,9 +478,12 @@
 
     /* we want to ignore HUPs and WINCH while we're busy processing one */
     sigaddset(&sa.sa_mask, SIGHUP);
+    sigaddset(&sa.sa_mask, SIGWINCH);
     sa.sa_handler = restart;
     if (sigaction(SIGHUP, &sa, NULL) < 0)
        ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, 
"sigaction(SIGHUP)");
+    if (sigaction(SIGWINCH, &sa, NULL) < 0)
+       ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, 
+"sigaction(SIGWINCH)");
 #else
     if (!one_process) {
        apr_signal(SIGSEGV, sig_coredump);
@@ -511,7 +512,7 @@
     apr_signal(SIGHUP, restart);
 #endif /* SIGHUP */
 #ifdef SIGWINCH
-    apr_signal(SIGWINCH, SIG_IGN);
+    apr_signal(SIGWINCH, restart);
 #endif /* SIGWINCH */
 #ifdef SIGPIPE
     apr_signal(SIGPIPE, SIG_IGN);
@@ -573,8 +574,6 @@
 
     (void) ap_update_child_status(AP_CHILD_THREAD_FROM_ID(my_child_num), 
SERVER_READY, (request_rec *) NULL);
 
-    apr_signal(SIGHUP, please_die_gracefully);
-
     ap_sync_scoreboard_image();
     while (!die_now) {
 
@@ -835,6 +834,7 @@
 
     if (one_process) {
        apr_signal(SIGHUP, please_die_gracefully);
+        apr_signal(SIGWINCH, please_die_gracefully);
        apr_signal(SIGINT, please_die_gracefully);
 #ifdef SIGQUIT
        apr_signal(SIGQUIT, SIG_DFL);
@@ -883,11 +883,12 @@
        }
 #endif
        RAISE_SIGSTOP(MAKE_CHILD);
-       /* Disable the restart signal handlers and enable the please_die_gracefully 
stuff.
-        * Note that since restart() just notes that a restart has been
-        * requested there's no race condition here.
-        */
-       apr_signal(SIGHUP, please_die_gracefully);
+        /* The child process doesn't do anything for SIGHUP or SIGWINCH.  Instead,
+         * the pod is used for signalling restart and graceful restart. 
+         */
+        apr_signal(SIGHUP, SIG_IGN);
+        apr_signal(SIGWINCH, SIG_IGN);
+
        apr_signal(SIGTERM, just_die);
         ap_scoreboard_image->parent[slot].process_status = SB_WORKING;
        child_main(slot);
@@ -1243,6 +1244,8 @@
 
     /* we've been told to restart */
     apr_signal(SIGHUP, SIG_IGN);
+    apr_signal(SIGWINCH, SIG_IGN);
+
     if (one_process) {
        /* not worth thinking about */
        return 1;
@@ -1282,10 +1285,8 @@
 #endif
     }
     else {
-       /* Kill 'em off */
-       if (unixd_killpg(getpgrp(), SIGHUP) < 0) {
-           ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg 
SIGHUP");
-       }
+       /* Kill 'em off for a non-graceful restart. */
+        ap_mpm_pod_killpg(pod, ap_daemons_limit);
        ap_reclaim_child_processes(0);          /* Not when just starting up */
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, ap_server_conf,
                    "SIGHUP received.  Attempting to restart");


-- 
Jeff Trawick | [EMAIL PROTECTED] | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Reply via email to