From: Jeff Trawick Date: Mon, 23 Jul 2012 12:15:39 +0000 (+0000) Subject: Follow up to r1363557: X-Git-Tag: 2.5.0-alpha~6597 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f5b52d406da70e8b4b4c3187d84962f8fef401c;p=apache Follow up to r1363557: Refactor with some existing code to slightly optimize thread tracking. Fix an implementation problem affecting statically linked MPMs which would break the ability to fail restart if a resource shortage was found immediately. Found by: rjung git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1364601 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index da447f774b..318da24bc9 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -171,6 +171,7 @@ static int ap_daemons_limit = 0; static int max_workers = 0; static int server_limit = 0; static int thread_limit = 0; +static int had_healthy_child = 0; static int dying = 0; static int workers_may_exit = 0; static int start_thread_may_exit = 0; @@ -183,7 +184,6 @@ static apr_uint32_t lingering_count = 0; /* Number of connections in lingerin static apr_uint32_t suspended_count = 0; /* Number of suspended connections */ static apr_uint32_t clogged_count = 0; /* Number of threads processing ssl conns */ static int resource_shortage = 0; -static int had_healthy_child = 0; static fd_queue_t *worker_queue; static fd_queue_info_t *worker_queue_info; static int mpm_state = AP_MPMQ_STARTING; @@ -2439,11 +2439,11 @@ static void perform_idle_server_maintenance(void) ++idle_thread_count; } if (status >= SERVER_READY && status < SERVER_GRACEFUL) { - ++active_thread_count; ++child_threads_active; } } } + active_thread_count += child_threads_active; if (any_dead_threads && totally_free_length < retained->idle_spawn_rate && free_length < MAX_SPAWN_RATE @@ -2947,6 +2947,7 @@ static int event_pre_config(apr_pool_t * pconf, apr_pool_t * plog, ap_daemons_limit = server_limit; threads_per_child = DEFAULT_THREADS_PER_CHILD; max_workers = ap_daemons_limit * threads_per_child; + had_healthy_child = 0; ap_extended_status = 0; return OK; diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 147f807d17..548fcaec60 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -122,6 +122,7 @@ static int ap_daemons_limit = 0; static int max_workers = 0; static int server_limit = 0; static int thread_limit = 0; +static int had_healthy_child = 0; static int dying = 0; static int workers_may_exit = 0; static int start_thread_may_exit = 0; @@ -129,7 +130,6 @@ static int listener_may_exit = 0; static int requests_this_child; static int num_listensocks = 0; static int resource_shortage = 0; -static int had_healthy_child = 0; static fd_queue_t *worker_queue; static fd_queue_info_t *worker_queue_info; static int mpm_state = AP_MPMQ_STARTING; @@ -1508,11 +1508,11 @@ static void perform_idle_server_maintenance(void) ++idle_thread_count; } if (status >= SERVER_READY && status < SERVER_GRACEFUL) { - ++active_thread_count; ++child_threads_active; } } } + active_thread_count += child_threads_active; if (any_dead_threads && totally_free_length < retained->idle_spawn_rate && free_length < MAX_SPAWN_RATE && (!ps->pid /* no process in the slot */ @@ -2028,6 +2028,7 @@ static int worker_pre_config(apr_pool_t *pconf, apr_pool_t *plog, ap_daemons_limit = server_limit; threads_per_child = DEFAULT_THREADS_PER_CHILD; max_workers = ap_daemons_limit * threads_per_child; + had_healthy_child = 0; ap_extended_status = 0; return OK;