Lines 171-176
static int max_workers = 0; /* Max
Link Here
|
171 |
static int server_limit = 0; /* ServerLimit */ |
171 |
static int server_limit = 0; /* ServerLimit */ |
172 |
static int thread_limit = 0; /* ThreadLimit */ |
172 |
static int thread_limit = 0; /* ThreadLimit */ |
173 |
static int had_healthy_child = 0; |
173 |
static int had_healthy_child = 0; |
|
|
174 |
static int remaining_children_to_start = 0; |
174 |
static volatile int dying = 0; |
175 |
static volatile int dying = 0; |
175 |
static volatile int workers_may_exit = 0; |
176 |
static volatile int workers_may_exit = 0; |
176 |
static volatile int start_thread_may_exit = 0; |
177 |
static volatile int start_thread_may_exit = 0; |
Lines 2766-2776
static int make_child(server_rec * s, int slot, in
Link Here
|
2766 |
} |
2767 |
} |
2767 |
|
2768 |
|
2768 |
/* start up a bunch of children */ |
2769 |
/* start up a bunch of children */ |
2769 |
static void startup_children(int number_to_start) |
2770 |
static void startup_children(void) |
2770 |
{ |
2771 |
{ |
2771 |
int i; |
2772 |
int i; |
2772 |
|
2773 |
|
2773 |
for (i = 0; number_to_start && i < server_limit; ++i) { |
2774 |
for (i = 0; remaining_children_to_start && i < server_limit; ++i) { |
2774 |
if (ap_scoreboard_image->parent[i].pid != 0) { |
2775 |
if (ap_scoreboard_image->parent[i].pid != 0) { |
2775 |
continue; |
2776 |
continue; |
2776 |
} |
2777 |
} |
Lines 2777-2783
static int make_child(server_rec * s, int slot, in
Link Here
|
2777 |
if (make_child(ap_server_conf, i, i % retained->mpm->num_buckets) < 0) { |
2778 |
if (make_child(ap_server_conf, i, i % retained->mpm->num_buckets) < 0) { |
2778 |
break; |
2779 |
break; |
2779 |
} |
2780 |
} |
2780 |
--number_to_start; |
2781 |
--remaining_children_to_start; |
2781 |
} |
2782 |
} |
2782 |
} |
2783 |
} |
2783 |
|
2784 |
|
Lines 2989-2997
static void perform_idle_server_maintenance(int ch
Link Here
|
2989 |
} |
2990 |
} |
2990 |
} |
2991 |
} |
2991 |
|
2992 |
|
2992 |
static void server_main_loop(int remaining_children_to_start) |
2993 |
static void server_main_loop(void) |
2993 |
{ |
2994 |
{ |
2994 |
int num_buckets = retained->mpm->num_buckets; |
2995 |
int num_buckets = retained->mpm->num_buckets; |
|
|
2996 |
int startup_done = 0; |
2995 |
int child_slot; |
2997 |
int child_slot; |
2996 |
apr_exit_why_e exitwhy; |
2998 |
apr_exit_why_e exitwhy; |
2997 |
int status, processed_status; |
2999 |
int status, processed_status; |
Lines 3085-3097
static void perform_idle_server_maintenance(int ch
Link Here
|
3085 |
*/ |
3087 |
*/ |
3086 |
continue; |
3088 |
continue; |
3087 |
} |
3089 |
} |
3088 |
else if (remaining_children_to_start) { |
3090 |
else if (!startup_done && remaining_children_to_start) { |
3089 |
/* we hit a 1 second timeout in which none of the previous |
3091 |
/* we hit a 1 second timeout in which none of the previous |
3090 |
* generation of children needed to be reaped... so assume |
3092 |
* generation of children needed to be reaped... so assume |
3091 |
* they're all done, and pick up the slack if any is left. |
3093 |
* they're all done, and pick up the slack if any is left. |
3092 |
*/ |
3094 |
*/ |
3093 |
startup_children(remaining_children_to_start); |
3095 |
startup_children(); |
3094 |
remaining_children_to_start = 0; |
3096 |
/* Don't reset remaining_children_to_start since in case of |
|
|
3097 |
* scoreboard full we still want one for one replacement of |
3098 |
* exiting processes until StartServers is satisfied. |
3099 |
*/ |
3100 |
startup_done = 1; |
3095 |
/* In any event we really shouldn't do the code below because |
3101 |
/* In any event we really shouldn't do the code below because |
3096 |
* few of the servers we just started are in the IDLE state |
3102 |
* few of the servers we just started are in the IDLE state |
3097 |
* yet, so we'd mistakenly create an extra server. |
3103 |
* yet, so we'd mistakenly create an extra server. |
Lines 3108-3114
static void perform_idle_server_maintenance(int ch
Link Here
|
3108 |
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) |
3114 |
static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) |
3109 |
{ |
3115 |
{ |
3110 |
int num_buckets = retained->mpm->num_buckets; |
3116 |
int num_buckets = retained->mpm->num_buckets; |
3111 |
int remaining_children_to_start; |
|
|
3112 |
int i; |
3117 |
int i; |
3113 |
|
3118 |
|
3114 |
ap_log_pid(pconf, ap_pid_fname); |
3119 |
ap_log_pid(pconf, ap_pid_fname); |
Lines 3133-3138
static int event_run(apr_pool_t * _pconf, apr_pool
Link Here
|
3133 |
active_daemons_limit = num_buckets; |
3138 |
active_daemons_limit = num_buckets; |
3134 |
if (ap_daemons_to_start < num_buckets) |
3139 |
if (ap_daemons_to_start < num_buckets) |
3135 |
ap_daemons_to_start = num_buckets; |
3140 |
ap_daemons_to_start = num_buckets; |
|
|
3141 |
else if (ap_daemons_to_start > active_daemons_limit) |
3142 |
ap_daemons_to_start = active_daemons_limit; |
3136 |
/* We want to create as much children at a time as the number of buckets, |
3143 |
/* We want to create as much children at a time as the number of buckets, |
3137 |
* so to optimally accept connections (evenly distributed across buckets). |
3144 |
* so to optimally accept connections (evenly distributed across buckets). |
3138 |
* Thus min_spare_threads should at least maintain num_buckets children, |
3145 |
* Thus min_spare_threads should at least maintain num_buckets children, |
Lines 3154-3164
static int event_run(apr_pool_t * _pconf, apr_pool
Link Here
|
3154 |
* supposed to start up without the 1 second penalty between each fork. |
3161 |
* supposed to start up without the 1 second penalty between each fork. |
3155 |
*/ |
3162 |
*/ |
3156 |
remaining_children_to_start = ap_daemons_to_start; |
3163 |
remaining_children_to_start = ap_daemons_to_start; |
3157 |
if (remaining_children_to_start > active_daemons_limit) { |
|
|
3158 |
remaining_children_to_start = active_daemons_limit; |
3159 |
} |
3160 |
if (!retained->mpm->was_graceful) { |
3164 |
if (!retained->mpm->was_graceful) { |
3161 |
startup_children(remaining_children_to_start); |
3165 |
startup_children(); |
3162 |
remaining_children_to_start = 0; |
3166 |
remaining_children_to_start = 0; |
3163 |
} |
3167 |
} |
3164 |
else { |
3168 |
else { |
Lines 3177-3183
static int event_run(apr_pool_t * _pconf, apr_pool
Link Here
|
3177 |
|
3181 |
|
3178 |
retained->mpm->mpm_state = AP_MPMQ_RUNNING; |
3182 |
retained->mpm->mpm_state = AP_MPMQ_RUNNING; |
3179 |
|
3183 |
|
3180 |
server_main_loop(remaining_children_to_start); |
3184 |
server_main_loop(); |
3181 |
retained->mpm->mpm_state = AP_MPMQ_STOPPING; |
3185 |
retained->mpm->mpm_state = AP_MPMQ_STOPPING; |
3182 |
|
3186 |
|
3183 |
if (retained->mpm->shutdown_pending && retained->mpm->is_ungraceful) { |
3187 |
if (retained->mpm->shutdown_pending && retained->mpm->is_ungraceful) { |