httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject [PATCH] smooth graceful restarts for prefork using sysvsems
Date Thu, 13 Jun 2002 22:31:09 GMT
This solves the problem for me.  But perhaps the log level should be
different when the generation number has changed (i.e., okay to fail
since the parent as restarted).

The 2.9-year-old and I are on our own for a few hours so it is pretty
much impossible for me to sanity check this now.

We've been running fairly similar code in worker for a while, though
the way it shuts down is different.

Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.266
diff -u -r1.266 prefork.c
--- server/mpm/prefork/prefork.c	7 Jun 2002 14:08:05 -0000	1.266
+++ server/mpm/prefork/prefork.c	13 Jun 2002 22:21:52 -0000
@@ -172,6 +172,7 @@
 #ifndef MULTITHREAD
 static int my_child_num;
 #endif
+ap_generation_t volatile ap_my_generation=0;
 
 #ifdef TPF
 int tpf_child = 0;
@@ -240,7 +241,14 @@
     apr_status_t rv = apr_proc_mutex_lock(accept_mutex);
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't grab the accept mutex");
-        exit(APEXIT_CHILDFATAL);
+
+        if (ap_my_generation != 
+            ap_scoreboard_image->global->running_generation) {
+            clean_child_exit(0);
+        }
+        else {
+            exit(APEXIT_CHILDFATAL);
+        }
     }
 }
 
@@ -249,7 +257,14 @@
     apr_status_t rv = apr_proc_mutex_unlock(accept_mutex);
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't release the accept mutex");
-        exit(APEXIT_CHILDFATAL);
+
+        if (ap_my_generation != 
+            ap_scoreboard_image->global->running_generation) {
+            clean_child_exit(0);
+        }
+        else {
+            exit(APEXIT_CHILDFATAL);
+        }
     }
 }
 
@@ -364,7 +379,6 @@
 static int volatile shutdown_pending;
 static int volatile restart_pending;
 static int volatile is_graceful;
-ap_generation_t volatile ap_my_generation=0;
 
 static void sig_term(int sig)
 {

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message