static void scan_busylist()

in modules/fcgid/fcgid_pm_main.c [115:156]


static void scan_busylist(server_rec * main_server)
{
    fcgid_procnode *current_node;
    fcgid_procnode *proc_table;
    apr_time_t last_active_time;
    apr_time_t now = apr_time_now();
    fcgid_server_conf *sconf =
        ap_get_module_config(main_server->module_config,
                             &fcgid_module);

    /* Should I check the busy list? */
    if (procmgr_must_exit()
        || apr_time_sec(now) - apr_time_sec(lastbusyscan) <=
        sconf->busy_scan_interval)
        return;
    lastbusyscan = now;

    /* Check busy list */
    proc_table = proctable_get_table_array();

    proctable_pm_lock(main_server);
    current_node = &proc_table[proctable_get_busy_list()->next_index];
    while (current_node != proc_table) {
        last_active_time = current_node->last_active_time;
        if (apr_time_sec(now) - apr_time_sec(last_active_time) >
            (current_node->cmdopts.busy_timeout)) {
            /* Protocol:
               1. diewhy init with FCGID_DIE_KILLSELF
               2. Process manager set diewhy to FCGID_DIE_BUSY_TIMEOUT and gracefully kill process while busy timeout
               3. Process manager forced kill process while busy timeout and diewhy is FCGID_DIE_BUSY_TIMEOUT
             */
            if (current_node->diewhy == FCGID_DIE_BUSY_TIMEOUT)
                proc_kill_force(current_node, main_server);
            else {
                current_node->diewhy = FCGID_DIE_BUSY_TIMEOUT;
                proc_kill_gracefully(current_node, main_server);
            }
        }
        current_node = &proc_table[current_node->next_index];
    }
    proctable_pm_unlock(main_server);
}