]> granicus.if.org Git - apache/commitdiff
Follow up to r1363557:
authorJeff Trawick <trawick@apache.org>
Mon, 23 Jul 2012 12:15:39 +0000 (12:15 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 23 Jul 2012 12:15:39 +0000 (12:15 +0000)
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

server/mpm/event/event.c
server/mpm/worker/worker.c

index da447f774b99359f86d2869e393e65fa67d00cbd..318da24bc99725e02922fb10dd731807bfde71c3 100644 (file)
@@ -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;
index 147f807d17dfd2d1bb2b6a6523c8a6889255acbd..548fcaec609061b22acfe9c296af0396ef9e0d58 100644 (file)
@@ -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;