]> granicus.if.org Git - apache/commitdiff
Add ap_relieve_child_processess(), a non-infanticidal copy of
authorColm MacCarthaigh <colm@apache.org>
Sat, 27 Aug 2005 22:12:08 +0000 (22:12 +0000)
committerColm MacCarthaigh <colm@apache.org>
Sat, 27 Aug 2005 22:12:08 +0000 (22:12 +0000)
ap_reclaim_child_processes(). Allows us to waitpid() each process in the
scoreboard and each "extra" process with a single call.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@240465 13f79535-47bb-0310-9956-ffa450edef68

include/mpm_common.h
server/mpm_common.c

index 91fd0bd4c70cc0146bb1511cf9e1c2b555da4750..360ea4a37e7461fbfe09bce09c45fe78adebc153 100644 (file)
@@ -95,8 +95,25 @@ void ap_reclaim_child_processes(int terminate);
 #endif
 
 /**
- * Tell ap_reclaim_child_processes() about an MPM child process which has no
- * entry in the scoreboard.
+ * Catch any child processes that have been spawned by the parent process
+ * which have exited. This includes processes registered as "other_children".
+ * @warning This is only defined if the MPM defines 
+ *          AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
+ * @tip This function requires that some macros are defined by the MPM: <pre>
+ *  MPM_CHILD_PID -- Get the pid from the specified spot in the scoreboard
+ *  MPM_NOTE_CHILD_KILLED -- Note the child died in the scoreboard
+ * </pre>
+ * @tip The MPM child processes which are relieved are those listed
+ * in the scoreboard as well as those currently registered via
+ * ap_register_extra_mpm_process().
+ */
+#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
+void ap_relieve_child_processes(void);
+#endif
+
+/**
+ * Tell ap_reclaim_child_processes() and ap_relieve_child_processes() about 
+ * an MPM child process which has no entry in the scoreboard.
  * @warning This is only defined if the MPM defines
  *          AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
  * @param pid The process id of an MPM child process which should be
index 52aebd478a8b3ccd87f55cd95886428f50c11749..c55a79e0968503e92b2603317054bb28df03c6e6 100644 (file)
@@ -273,6 +273,38 @@ void ap_reclaim_child_processes(int terminate)
     } while (not_dead_yet > 0 &&
              action_table[cur_action].action != GIVEUP);
 }
+
+void ap_relieve_child_processes(void)
+{
+    int i;
+    extra_process_t *cur_extra;
+    int max_daemons;
+
+    ap_mpm_query(AP_MPMQ_MAX_DAEMON_USED, &max_daemons);
+
+    /* now see who is done */
+    for (i = 0; i < max_daemons; ++i) {
+        pid_t pid = MPM_CHILD_PID(i);
+
+        if (pid == 0) {
+            continue; /* not every scoreboard entry is in use */
+        }
+
+        if (reclaim_one_pid(pid, DO_NOTHING)) {
+            MPM_NOTE_CHILD_KILLED(i);
+        }
+    }
+
+    cur_extra = extras;
+    while (cur_extra) {
+        extra_process_t *next = cur_extra->next;
+
+        if (reclaim_one_pid(cur_extra->pid, DO_NOTHING)) {
+            AP_DEBUG_ASSERT(1 == ap_unregister_extra_mpm_process(cur_extra->pid));
+        }
+        cur_extra = next;
+    }
+}
 #endif /* AP_MPM_WANT_RECLAIM_CHILD_PROCESSES */
 
 #ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT