in modules/fcgid/fcgid_pm_main.c [408:466]
static void kill_all_subprocess(server_rec *main_server)
{
apr_time_t waittime = 1024 * 16;
size_t i, table_size = proctable_get_table_size();
int not_dead_yet;
int cur_action, next_action;
apr_time_t starttime = apr_time_now();
struct {
action_t action;
apr_time_t action_time;
} action_table[] = {
{DO_NOTHING, 0}, /* dummy entry for iterations where
* we reap children but take no action
* against stragglers
*/
{KILL_GRACEFULLY, apr_time_from_sec(0)},
{KILL_GRACEFULLY, apr_time_from_sec(1)},
{KILL_FORCEFULLY, apr_time_from_sec(8)},
{HARD_WAIT, apr_time_from_sec(8)}
};
fcgid_procnode *proc_table = proctable_get_table_array();
next_action = 1;
do {
apr_sleep(waittime);
/* don't let waittime get longer than 1 second; otherwise, we don't
* react quickly to the last child exiting, and taking action can
* be delayed
*/
waittime = waittime * 4;
if (waittime > apr_time_from_sec(1)) {
waittime = apr_time_from_sec(1);
}
/* see what action to take, if any */
if (action_table[next_action].action_time <= apr_time_now() - starttime) {
cur_action = next_action;
++next_action;
}
else {
cur_action = 0; /* index of DO_NOTHING entry */
}
/* now see who is done */
not_dead_yet = 0;
for (i = 0; i < table_size; i++) {
if (!proc_table[i].proc_pool) {
continue; /* unused */
}
if (!reclaim_one_pid(main_server, &proc_table[i],
action_table[cur_action].action)) {
++not_dead_yet;
}
}
} while (not_dead_yet &&
action_table[cur_action].action != HARD_WAIT);
}