]> granicus.if.org Git - apache/commitdiff
Defer starting the listener until we have at least tried to start all the worker
authorBill Stoddard <stoddard@apache.org>
Wed, 1 May 2002 15:06:44 +0000 (15:06 +0000)
committerBill Stoddard <stoddard@apache.org>
Wed, 1 May 2002 15:06:44 +0000 (15:06 +0000)
threads.  We want to get the workers in the pool of available threads ASAP
to keep perform_idle_server_maintenance from thrashing and starting too
many processes prematurely.  The code before this patch would dribble workers
into the worker pool over an extended period of time and this prevented
perform_idle_server_maintenance from accurately deciding when new processes
were needed.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94889 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/worker/worker.c

index 65643848617080007ff2871e0d66a48efc82123e..54b461bf13acb2950e1c11aa19c4591c69146fa1 100644 (file)
@@ -999,6 +999,7 @@ static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
     apr_status_t rv;
     int i;
     int threads_created = 0;
+    int listener_started = 0;
     int loops;
     int prev_threads_created;
 
@@ -1061,12 +1062,11 @@ static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
                 clean_child_exit(APEXIT_CHILDFATAL);
             }
             threads_created++;
-            if (threads_created == 1) {
-                /* now that we have a worker thread, it makes sense to create
-                 * a listener thread (we don't want a listener without a worker!)
-                 */
-                create_listener_thread(ts);
-            }
+        }
+        /* Start the listener only when there are workers available */
+        if (!listener_started && threads_created) {
+            create_listener_thread(ts);
+            listener_started = 1;
         }
         if (start_thread_may_exit || threads_created == ap_threads_per_child) {
             break;