static void perform_idle_server_maintenance(void)
{
    int i, j;
    int idle_thread_count;
    worker_score *ws;
    process_score *ps;
    int free_length;
    int totally_free_length = 0;
    int free_slots[MAX_SPAWN_RATE];
    int last_non_dead;
    int total_non_dead;
    int active_thread_count = 0;
    free_length = 0;
    idle_thread_count = 0;
    last_non_dead = -1;
    total_non_dead = 0;
    for (i = 0; i < ap_daemons_limit; ++i) {
        int status = SERVER_DEAD;
        int any_dying_threads = 0;
        int any_dead_threads = 0;
        int all_dead_threads = 1;
        if (i >= retained->max_daemons_limit
            && totally_free_length == retained->idle_spawn_rate)
            break;
        ps = &ap_scoreboard_image->parent[i];
        for (j = 0; j < threads_per_child; j++) {
            ws = &ap_scoreboard_image->servers[i][j];
            status = ws->status;
            any_dying_threads = any_dying_threads ||
                (status == SERVER_GRACEFUL);
            any_dead_threads = any_dead_threads || (status == SERVER_DEAD);
            all_dead_threads = all_dead_threads &&
                (status == SERVER_DEAD || status == SERVER_GRACEFUL);
            if (ps->pid != 0) {
                if (status <= SERVER_READY && !ps->quiescing && !ps->not_accepting
                    && ps->generation == retained->my_generation)
                {
                    ++idle_thread_count;
                }
                if (status >= SERVER_READY && status < SERVER_GRACEFUL) {
                    ++active_thread_count;
                }
            }
        }
        if (any_dead_threads
            && totally_free_length < retained->idle_spawn_rate
            && free_length < MAX_SPAWN_RATE
            && (!ps->pid
                  || ps->quiescing)) {
            if (all_dead_threads) {
                free_slots[free_length] = free_slots[totally_free_length];
                free_slots[totally_free_length++] = i;
            }
            else {
                free_slots[free_length] = i;
            }
            ++free_length;
        }
        if (!any_dying_threads) {
            last_non_dead = i;
            ++total_non_dead;
        }
    }
    if (retained->sick_child_detected) {
        if (active_thread_count > 0) {
            retained->sick_child_detected = 0;
        }
        else {
            shutdown_pending = 1;
            child_fatal = 1;
            ap_log_error(APLOG_MARK, APLOG_ALERT, 0,
                         ap_server_conf, APLOGNO(00483)
                         "No active workers found..."
                         " Apache is exiting!");
            return;
        }
    }
    retained->max_daemons_limit = last_non_dead + 1;
    if (idle_thread_count > max_spare_threads) {
        ap_event_pod_signal(pod, TRUE);
        retained->idle_spawn_rate = 1;
    }
    else if (idle_thread_count < min_spare_threads) {
        if (free_length == 0) {
            if (active_thread_count >= ap_daemons_limit * threads_per_child) {
                if (!retained->maxclients_reported) {
                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(00484)
                                 "server reached MaxRequestWorkers setting, "
                                 "consider raising the MaxRequestWorkers "
                                 "setting");
                    retained->maxclients_reported = 1;
                }
            }
            else {
                ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(00485)
                             "scoreboard is full, not at MaxRequestWorkers");
            }
            retained->idle_spawn_rate = 1;
        }
        else {
            if (free_length > retained->idle_spawn_rate) {
                free_length = retained->idle_spawn_rate;
            }
            if (retained->idle_spawn_rate >= 8) {
                ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(00486)
                             "server seems busy, (you may need "
                             "to increase StartServers, ThreadsPerChild "
                             "or Min/MaxSpareThreads), "
                             "spawning %d children, there are around %d idle "
                             "threads, and %d total children", free_length,
                             idle_thread_count, total_non_dead);
            }
            for (i = 0; i < free_length; ++i) {
                make_child(ap_server_conf, free_slots[i]);
            }
            if (retained->hold_off_on_exponential_spawning) {
                --retained->hold_off_on_exponential_spawning;
            }
            else if (retained->idle_spawn_rate < MAX_SPAWN_RATE) {
                retained->idle_spawn_rate *= 2;
            }
        }
    }
    else {
        retained->idle_spawn_rate = 1;
    }
}
['static void perform_idle_server_maintenance(void)\n{\n    int i, j;\n    int idle_thread_count;\n    worker_score *ws;\n    process_score *ps;\n    int free_length;\n    int totally_free_length = 0;\n    int free_slots[MAX_SPAWN_RATE];\n    int last_non_dead;\n    int total_non_dead;\n    int active_thread_count = 0;\n    free_length = 0;\n    idle_thread_count = 0;\n    last_non_dead = -1;\n    total_non_dead = 0;\n    for (i = 0; i < ap_daemons_limit; ++i) {\n        int status = SERVER_DEAD;\n        int any_dying_threads = 0;\n        int any_dead_threads = 0;\n        int all_dead_threads = 1;\n        if (i >= retained->max_daemons_limit\n            && totally_free_length == retained->idle_spawn_rate)\n            break;\n        ps = &ap_scoreboard_image->parent[i];\n        for (j = 0; j < threads_per_child; j++) {\n            ws = &ap_scoreboard_image->servers[i][j];\n            status = ws->status;\n            any_dying_threads = any_dying_threads ||\n                (status == SERVER_GRACEFUL);\n            any_dead_threads = any_dead_threads || (status == SERVER_DEAD);\n            all_dead_threads = all_dead_threads &&\n                (status == SERVER_DEAD || status == SERVER_GRACEFUL);\n            if (ps->pid != 0) {\n                if (status <= SERVER_READY && !ps->quiescing && !ps->not_accepting\n                    && ps->generation == retained->my_generation)\n                {\n                    ++idle_thread_count;\n                }\n                if (status >= SERVER_READY && status < SERVER_GRACEFUL) {\n                    ++active_thread_count;\n                }\n            }\n        }\n        if (any_dead_threads\n            && totally_free_length < retained->idle_spawn_rate\n            && free_length < MAX_SPAWN_RATE\n            && (!ps->pid\n                  || ps->quiescing)) {\n            if (all_dead_threads) {\n                free_slots[free_length] = free_slots[totally_free_length];\n                free_slots[totally_free_length++] = i;\n            }\n            else {\n                free_slots[free_length] = i;\n            }\n            ++free_length;\n        }\n        if (!any_dying_threads) {\n            last_non_dead = i;\n            ++total_non_dead;\n        }\n    }\n    if (retained->sick_child_detected) {\n        if (active_thread_count > 0) {\n            retained->sick_child_detected = 0;\n        }\n        else {\n            shutdown_pending = 1;\n            child_fatal = 1;\n            ap_log_error(APLOG_MARK, APLOG_ALERT, 0,\n                         ap_server_conf, APLOGNO(00483)\n                         "No active workers found..."\n                         " Apache is exiting!");\n            return;\n        }\n    }\n    retained->max_daemons_limit = last_non_dead + 1;\n    if (idle_thread_count > max_spare_threads) {\n        ap_event_pod_signal(pod, TRUE);\n        retained->idle_spawn_rate = 1;\n    }\n    else if (idle_thread_count < min_spare_threads) {\n        if (free_length == 0) {\n            if (active_thread_count >= ap_daemons_limit * threads_per_child) {\n                if (!retained->maxclients_reported) {\n                    ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(00484)\n                                 "server reached MaxRequestWorkers setting, "\n                                 "consider raising the MaxRequestWorkers "\n                                 "setting");\n                    retained->maxclients_reported = 1;\n                }\n            }\n            else {\n                ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(00485)\n                             "scoreboard is full, not at MaxRequestWorkers");\n            }\n            retained->idle_spawn_rate = 1;\n        }\n        else {\n            if (free_length > retained->idle_spawn_rate) {\n                free_length = retained->idle_spawn_rate;\n            }\n            if (retained->idle_spawn_rate >= 8) {\n                ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(00486)\n                             "server seems busy, (you may need "\n                             "to increase StartServers, ThreadsPerChild "\n                             "or Min/MaxSpareThreads), "\n                             "spawning %d children, there are around %d idle "\n                             "threads, and %d total children", free_length,\n                             idle_thread_count, total_non_dead);\n            }\n            for (i = 0; i < free_length; ++i) {\n                make_child(ap_server_conf, free_slots[i]);\n            }\n            if (retained->hold_off_on_exponential_spawning) {\n                --retained->hold_off_on_exponential_spawning;\n            }\n            else if (retained->idle_spawn_rate < MAX_SPAWN_RATE) {\n                retained->idle_spawn_rate *= 2;\n            }\n        }\n    }\n    else {\n        retained->idle_spawn_rate = 1;\n    }\n}']