diff options
Diffstat (limited to 'server/mpm/event/event.c')
-rw-r--r-- | server/mpm/event/event.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index 2418471f..baeb5a76 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -1114,7 +1114,7 @@ read_request: if (cs->pub.state == CONN_STATE_WRITE_COMPLETION) { ap_filter_t *output_filter = c->output_filters; apr_status_t rv; - ap_update_child_status_from_conn(sbh, SERVER_BUSY_WRITE, c); + ap_update_child_status(sbh, SERVER_BUSY_WRITE, NULL); while (output_filter->next != NULL) { output_filter = output_filter->next; } @@ -1910,7 +1910,8 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy) } ap_update_child_status_from_indexes(process_slot, thread_slot, - dying ? SERVER_GRACEFUL : SERVER_READY, NULL); + dying ? SERVER_GRACEFUL + : SERVER_READY, NULL); worker_pop: if (workers_may_exit) { break; @@ -1965,9 +1966,8 @@ static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *dummy) } ap_update_child_status_from_indexes(process_slot, thread_slot, - dying ? SERVER_DEAD : - SERVER_GRACEFUL, - (request_rec *) NULL); + dying ? SERVER_DEAD + : SERVER_GRACEFUL, NULL); apr_thread_exit(thd, APR_SUCCESS); return NULL; @@ -2017,8 +2017,7 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) thread_starter *ts = dummy; apr_thread_t **threads = ts->threads; apr_threadattr_t *thread_attr = ts->threadattr; - int child_num_arg = ts->child_num_arg; - int my_child_num = child_num_arg; + int my_child_num = ts->child_num_arg; proc_info *my_info; apr_status_t rv; int i; @@ -2102,7 +2101,7 @@ static void *APR_THREAD_FUNC start_threads(apr_thread_t * thd, void *dummy) /* threads_per_child does not include the listener thread */ for (i = 0; i < threads_per_child; i++) { int status = - ap_scoreboard_image->servers[child_num_arg][i].status; + ap_scoreboard_image->servers[my_child_num][i].status; if (status != SERVER_GRACEFUL && status != SERVER_DEAD) { continue; @@ -2524,13 +2523,14 @@ static void perform_idle_server_maintenance(int child_bucket, int num_buckets) int all_dead_threads = 1; int child_threads_active = 0; - if (i >= retained->max_daemons_limit - && totally_free_length == retained->idle_spawn_rate[child_bucket]) + if (i >= retained->max_daemons_limit && + totally_free_length == retained->idle_spawn_rate[child_bucket]) { /* short cut if all active processes have been examined and * enough empty scoreboard slots have been found */ break; + } ps = &ap_scoreboard_image->parent[i]; for (j = 0; j < threads_per_child; j++) { ws = &ap_scoreboard_image->servers[i][j]; @@ -2728,8 +2728,7 @@ static void server_main_loop(int remaining_children_to_start, int num_buckets) for (i = 0; i < threads_per_child; i++) ap_update_child_status_from_indexes(child_slot, i, - SERVER_DEAD, - (request_rec *) NULL); + SERVER_DEAD, NULL); event_note_child_killed(child_slot, 0, 0); ps = &ap_scoreboard_image->parent[child_slot]; @@ -2830,10 +2829,16 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s) ap_daemons_limit = num_buckets; if (ap_daemons_to_start < num_buckets) ap_daemons_to_start = num_buckets; - if (min_spare_threads < threads_per_child * num_buckets) - min_spare_threads = threads_per_child * num_buckets; - if (max_spare_threads < min_spare_threads + threads_per_child * num_buckets) - max_spare_threads = min_spare_threads + threads_per_child * num_buckets; + /* We want to create as much children at a time as the number of buckets, + * so to optimally accept connections (evenly distributed accross buckets). + * Thus min_spare_threads should at least maintain num_buckets children, + * and max_spare_threads allow num_buckets more children w/o triggering + * immediately (e.g. num_buckets idle threads margin, one per bucket). + */ + if (min_spare_threads < threads_per_child * (num_buckets - 1) + num_buckets) + min_spare_threads = threads_per_child * (num_buckets - 1) + num_buckets; + if (max_spare_threads < min_spare_threads + (threads_per_child + 1) * num_buckets) + max_spare_threads = min_spare_threads + (threads_per_child + 1) * num_buckets; /* If we're doing a graceful_restart then we're going to see a lot * of children exiting immediately when we get into the main loop |