httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r240466 - /httpd/httpd/trunk/server/mpm/prefork/prefork.c
Date Sat, 27 Aug 2005 22:16:54 GMT
Author: colm
Date: Sat Aug 27 15:16:46 2005
New Revision: 240466

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

Remove as many ghastly scoreboard loops from the graceful-shutdown code, and
replace with the new ap_relieve_child_processes() call. Add a sleep() call now,
as we lost the timeout inherent in ap_wait_or_timeout(). 1 second seems a sane
choice.


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=240466&r1=240465&r2=240466&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Sat Aug 27 15:16:46 2005
@@ -1117,10 +1117,6 @@
          * all done to exit.
          */
         int active_children;
-        apr_exit_why_e exitwhy;
-        int status;
-        int child_slot;
-        apr_proc_t pid;
         apr_time_t cutoff = 0;
 
         /* Stop listening */
@@ -1133,25 +1129,14 @@
         active_children = 0;
         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. */
-                kill(ap_scoreboard_image->parent[index].pid, AP_SIG_GRACEFUL);
+                kill(MPM_CHILD_PID(index), AP_SIG_GRACEFUL);
                 active_children++;
             }
         }
 
         /* Allow each child which actually finished to exit */
-        for (; active_children; active_children--) {
-            ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
-            
-            if (pid.pid != -1) {
-                child_slot = find_child_by_pid(&pid);
-                if (child_slot >= 0) {
-                    (void) ap_update_child_status_from_indexes(child_slot, 0, 
-                                            SERVER_DEAD, (request_rec *) NULL);
-                }
-            }
-        }
+        ap_relieve_child_processes();
 
         /* cleanup pid file */
         {
@@ -1175,24 +1160,18 @@
         /* Don't really exit until each child has finished */
         shutdown_pending = 0;
         do {
+            /* Pause for a second */
+            sleep(1);
+                
+            /* Relieve any children which have now exited */
+            ap_relieve_child_processes();
+            
             active_children = 0;
             for (index = 0; index < ap_daemons_limit; ++index) {
-                if (ap_scoreboard_image->servers[index][0].status != SERVER_DEAD) {
-                    if (kill(ap_scoreboard_image->parent[index].pid, 0) == 0) {
-                        active_children++;
-                    }
-                }
-            }
-
-            for (index = 0; index < active_children; ++index) {
-                /* Gather any now finished children */
-                ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
-
-                if (pid.pid != -1) {
-                    child_slot = find_child_by_pid(&pid);
-                    if (child_slot >= 0) {
-                        (void) ap_update_child_status_from_indexes(child_slot, 
-                                         0, SERVER_DEAD, (request_rec *) NULL);
+                if (MPM_CHILD_PID(index) != 0) {
+                    if (kill(MPM_CHILD_PID(index), 0) == 0) {
+                            active_children = 1;
+                            /* Having just one child is enough to stay around */
                     }
                 }
             }



Mime
View raw message