From: Aaron Bannert Date: Sun, 28 Apr 2002 23:28:52 +0000 (+0000) Subject: Rename the worker_stack_interrupt_all() function as worker_stack_terminate(). X-Git-Tag: 2.0.36~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb83b744d32d34257d188c8cee3a0053bbb933f1;p=apache Rename the worker_stack_interrupt_all() function as worker_stack_terminate(). Also, broadcast a signal after we set the terminate flag on the worker stack. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94846 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/experimental/threadpool/threadpool.c b/server/mpm/experimental/threadpool/threadpool.c index e2ba46682e..f1b496c6b3 100644 --- a/server/mpm/experimental/threadpool/threadpool.c +++ b/server/mpm/experimental/threadpool/threadpool.c @@ -361,6 +361,7 @@ static apr_status_t worker_stack_pop(worker_stack *stack, if ((rv = apr_thread_mutex_lock(stack->mutex)) != APR_SUCCESS) { return rv; } + AP_DEBUG_ASSERT(stack->nelts >= 0); while ((stack->nelts == 0) && (!stack->terminated)) { rv = apr_thread_cond_wait(stack->cond, stack->mutex); if (rv != APR_SUCCESS) { @@ -385,7 +386,7 @@ static apr_status_t worker_stack_pop(worker_stack *stack, return APR_SUCCESS; } -static apr_status_t worker_stack_interrupt_all(worker_stack *stack) +static apr_status_t worker_stack_terminate(worker_stack *stack) { apr_status_t rv; worker_wakeup_info *worker; @@ -394,6 +395,10 @@ static apr_status_t worker_stack_interrupt_all(worker_stack *stack) return rv; } stack->terminated = 1; + /* Wake up the listener thread. Although there will never be + * more than one thread blocking on this condition, broadcast + * just in case. */ + apr_thread_cond_broadcast(stack->cond); while (stack->nelts) { worker = stack->stack[--stack->nelts]; apr_thread_mutex_lock(worker->mutex); @@ -472,7 +477,7 @@ static void signal_threads(int mode) */ if (mode == ST_UNGRACEFUL) { workers_may_exit = 1; - worker_stack_interrupt_all(idle_worker_stack); + worker_stack_terminate(idle_worker_stack); } } @@ -994,7 +999,6 @@ static void *listener_thread(apr_thread_t *thd, void * dummy) } workers_may_exit = 1; - worker_stack_interrupt_all(idle_worker_stack); if (worker) { apr_thread_mutex_lock(worker->mutex); worker->state = WORKER_TERMINATED; @@ -1006,6 +1010,7 @@ static void *listener_thread(apr_thread_t *thd, void * dummy) apr_thread_cond_signal(worker->cond); apr_thread_mutex_unlock(worker->mutex); } + worker_stack_terminate(idle_worker_stack); dying = 1; ap_scoreboard_image->parent[process_slot].quiescing = 1;