Lines 173-182
static int threads_per_child = 0; /* ThreadsPerChild */
Link Here
|
173 |
static int ap_daemons_to_start = 0; /* StartServers */ |
173 |
static int ap_daemons_to_start = 0; /* StartServers */ |
174 |
static int min_spare_threads = 0; /* MinSpareThreads */ |
174 |
static int min_spare_threads = 0; /* MinSpareThreads */ |
175 |
static int max_spare_threads = 0; /* MaxSpareThreads */ |
175 |
static int max_spare_threads = 0; /* MaxSpareThreads */ |
176 |
static int ap_daemons_limit = 0; |
176 |
static int ap_daemons_limit = 0; /* MaxRequestWorkers / ThreadsPerChild */ |
177 |
static int max_workers = 0; /* MaxRequestWorkers */ |
177 |
static int max_workers = 0; /* MaxRequestWorkers */ |
178 |
static int server_limit = 0; /* ServerLimit */ |
178 |
static int server_limit = 0; /* ServerLimit */ |
179 |
static int thread_limit = 0; /* ThreadLimit */ |
179 |
static int thread_limit = 0; /* ThreadLimit */ |
|
|
180 |
static int sb_max_daemon_idx = 0; |
180 |
static int had_healthy_child = 0; |
181 |
static int had_healthy_child = 0; |
181 |
static int dying = 0; |
182 |
static int dying = 0; |
182 |
static int workers_may_exit = 0; |
183 |
static int workers_may_exit = 0; |
Lines 2797-2803
static void startup_children(int number_to_start)
Link Here
|
2797 |
{ |
2798 |
{ |
2798 |
int i; |
2799 |
int i; |
2799 |
|
2800 |
|
2800 |
for (i = 0; number_to_start && i < ap_daemons_limit; ++i) { |
2801 |
for (i = 0; number_to_start && i < sb_max_daemon_idx; ++i) { |
2801 |
if (ap_scoreboard_image->parent[i].pid != 0) { |
2802 |
if (ap_scoreboard_image->parent[i].pid != 0) { |
2802 |
continue; |
2803 |
continue; |
2803 |
} |
2804 |
} |
Lines 2828-2834
static void perform_idle_server_maintenance(int child_bucket, int num_buckets)
Link Here
|
2828 |
last_non_dead = -1; |
2829 |
last_non_dead = -1; |
2829 |
total_non_dead = 0; |
2830 |
total_non_dead = 0; |
2830 |
|
2831 |
|
2831 |
for (i = 0; i < ap_daemons_limit; ++i) { |
2832 |
for (i = 0; i < sb_max_daemon_idx; ++i) { |
2832 |
/* Initialization to satisfy the compiler. It doesn't know |
2833 |
/* Initialization to satisfy the compiler. It doesn't know |
2833 |
* that threads_per_child is always > 0 */ |
2834 |
* that threads_per_child is always > 0 */ |
2834 |
int status = SERVER_DEAD; |
2835 |
int status = SERVER_DEAD; |
Lines 3053-3059
static void server_main_loop(int remaining_children_to_start, int num_buckets)
Link Here
|
3053 |
retained->idle_spawn_rate[ps->bucket] = 1; |
3054 |
retained->idle_spawn_rate[ps->bucket] = 1; |
3054 |
} |
3055 |
} |
3055 |
else if (remaining_children_to_start |
3056 |
else if (remaining_children_to_start |
3056 |
&& child_slot < ap_daemons_limit) { |
3057 |
&& child_slot < sb_max_daemon_idx) { |
3057 |
/* we're still doing a 1-for-1 replacement of dead |
3058 |
/* we're still doing a 1-for-1 replacement of dead |
3058 |
* children with new children |
3059 |
* children with new children |
3059 |
*/ |
3060 |
*/ |
Lines 3149-3154
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3149 |
if (max_spare_threads < min_spare_threads + threads_per_child * num_buckets) |
3150 |
if (max_spare_threads < min_spare_threads + threads_per_child * num_buckets) |
3150 |
max_spare_threads = min_spare_threads + threads_per_child * num_buckets; |
3151 |
max_spare_threads = min_spare_threads + threads_per_child * num_buckets; |
3151 |
|
3152 |
|
|
|
3153 |
sb_max_daemon_idx = 10 * ap_daemons_limit; |
3154 |
if (sb_max_daemon_idx > server_limit) { |
3155 |
sb_max_daemon_idx = server_limit; |
3156 |
} |
3152 |
/* If we're doing a graceful_restart then we're going to see a lot |
3157 |
/* If we're doing a graceful_restart then we're going to see a lot |
3153 |
* of children exiting immediately when we get into the main loop |
3158 |
* of children exiting immediately when we get into the main loop |
3154 |
* below (because we just sent them AP_SIG_GRACEFUL). This happens pretty |
3159 |
* below (because we just sent them AP_SIG_GRACEFUL). This happens pretty |
Lines 3190-3196
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3190 |
* Kill child processes, tell them to call child_exit, etc... |
3195 |
* Kill child processes, tell them to call child_exit, etc... |
3191 |
*/ |
3196 |
*/ |
3192 |
for (i = 0; i < num_buckets; i++) { |
3197 |
for (i = 0; i < num_buckets; i++) { |
3193 |
ap_mpm_podx_killpg(all_buckets[i].pod, ap_daemons_limit, |
3198 |
ap_mpm_podx_killpg(all_buckets[i].pod, sb_max_daemon_idx, |
3194 |
AP_MPM_PODX_RESTART); |
3199 |
AP_MPM_PODX_RESTART); |
3195 |
} |
3200 |
} |
3196 |
ap_reclaim_child_processes(1, /* Start with SIGTERM */ |
3201 |
ap_reclaim_child_processes(1, /* Start with SIGTERM */ |
Lines 3214-3220
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3214 |
/* Close our listeners, and then ask our children to do same */ |
3219 |
/* Close our listeners, and then ask our children to do same */ |
3215 |
ap_close_listeners(); |
3220 |
ap_close_listeners(); |
3216 |
for (i = 0; i < num_buckets; i++) { |
3221 |
for (i = 0; i < num_buckets; i++) { |
3217 |
ap_mpm_podx_killpg(all_buckets[i].pod, ap_daemons_limit, |
3222 |
ap_mpm_podx_killpg(all_buckets[i].pod, sb_max_daemon_idx, |
3218 |
AP_MPM_PODX_GRACEFUL); |
3223 |
AP_MPM_PODX_GRACEFUL); |
3219 |
} |
3224 |
} |
3220 |
ap_relieve_child_processes(event_note_child_killed); |
3225 |
ap_relieve_child_processes(event_note_child_killed); |
Lines 3242-3248
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3242 |
ap_relieve_child_processes(event_note_child_killed); |
3247 |
ap_relieve_child_processes(event_note_child_killed); |
3243 |
|
3248 |
|
3244 |
active_children = 0; |
3249 |
active_children = 0; |
3245 |
for (index = 0; index < ap_daemons_limit; ++index) { |
3250 |
for (index = 0; index < sb_max_daemon_idx; ++index) { |
3246 |
if (ap_mpm_safe_kill(MPM_CHILD_PID(index), 0) == APR_SUCCESS) { |
3251 |
if (ap_mpm_safe_kill(MPM_CHILD_PID(index), 0) == APR_SUCCESS) { |
3247 |
active_children = 1; |
3252 |
active_children = 1; |
3248 |
/* Having just one child is enough to stay around */ |
3253 |
/* Having just one child is enough to stay around */ |
Lines 3257-3263
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3257 |
* really dead. |
3262 |
* really dead. |
3258 |
*/ |
3263 |
*/ |
3259 |
for (i = 0; i < num_buckets; i++) { |
3264 |
for (i = 0; i < num_buckets; i++) { |
3260 |
ap_mpm_podx_killpg(all_buckets[i].pod, ap_daemons_limit, |
3265 |
ap_mpm_podx_killpg(all_buckets[i].pod, sb_max_daemon_idx, |
3261 |
AP_MPM_PODX_RESTART); |
3266 |
AP_MPM_PODX_RESTART); |
3262 |
} |
3267 |
} |
3263 |
ap_reclaim_child_processes(1, event_note_child_killed); |
3268 |
ap_reclaim_child_processes(1, event_note_child_killed); |
Lines 3286-3292
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3286 |
" received. Doing graceful restart"); |
3291 |
" received. Doing graceful restart"); |
3287 |
/* wake up the children...time to die. But we'll have more soon */ |
3292 |
/* wake up the children...time to die. But we'll have more soon */ |
3288 |
for (i = 0; i < num_buckets; i++) { |
3293 |
for (i = 0; i < num_buckets; i++) { |
3289 |
ap_mpm_podx_killpg(all_buckets[i].pod, ap_daemons_limit, |
3294 |
ap_mpm_podx_killpg(all_buckets[i].pod, sb_max_daemon_idx, |
3290 |
AP_MPM_PODX_GRACEFUL); |
3295 |
AP_MPM_PODX_GRACEFUL); |
3291 |
} |
3296 |
} |
3292 |
|
3297 |
|
Lines 3301-3307
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
Link Here
|
3301 |
* pthreads are stealing signals from us left and right. |
3306 |
* pthreads are stealing signals from us left and right. |
3302 |
*/ |
3307 |
*/ |
3303 |
for (i = 0; i < num_buckets; i++) { |
3308 |
for (i = 0; i < num_buckets; i++) { |
3304 |
ap_mpm_podx_killpg(all_buckets[i].pod, ap_daemons_limit, |
3309 |
ap_mpm_podx_killpg(all_buckets[i].pod, sb_max_daemon_idx, |
3305 |
AP_MPM_PODX_RESTART); |
3310 |
AP_MPM_PODX_RESTART); |
3306 |
} |
3311 |
} |
3307 |
|
3312 |
|
Lines 3525-3530
static int event_pre_config(apr_pool_t * pconf, apr_pool_t * plog,
Link Here
|
3525 |
server_limit = DEFAULT_SERVER_LIMIT; |
3530 |
server_limit = DEFAULT_SERVER_LIMIT; |
3526 |
thread_limit = DEFAULT_THREAD_LIMIT; |
3531 |
thread_limit = DEFAULT_THREAD_LIMIT; |
3527 |
ap_daemons_limit = server_limit; |
3532 |
ap_daemons_limit = server_limit; |
|
|
3533 |
sb_max_daemon_idx = server_limit; |
3528 |
threads_per_child = DEFAULT_THREADS_PER_CHILD; |
3534 |
threads_per_child = DEFAULT_THREADS_PER_CHILD; |
3529 |
max_workers = ap_daemons_limit * threads_per_child; |
3535 |
max_workers = ap_daemons_limit * threads_per_child; |
3530 |
had_healthy_child = 0; |
3536 |
had_healthy_child = 0; |