From f0b69299d6c097fc43a27e328ea8702c8504cd58 Mon Sep 17 00:00:00 2001 From: Aaron Bannert Date: Sun, 28 Apr 2002 21:35:12 +0000 Subject: [PATCH] When we signal a condition variable, we need to own the lock that is associated with that condition variable. This isn't necessary for Solaris, but for Posix it is. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94839 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/experimental/threadpool/threadpool.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/mpm/experimental/threadpool/threadpool.c b/server/mpm/experimental/threadpool/threadpool.c index a75ad9fe5b..a1c122af99 100644 --- a/server/mpm/experimental/threadpool/threadpool.c +++ b/server/mpm/experimental/threadpool/threadpool.c @@ -939,10 +939,13 @@ static void *listener_thread(apr_thread_t *thd, void * dummy) signal_threads(ST_GRACEFUL); } if (csd != NULL) { - worker->csd = (apr_socket_t *)csd; + /* Wake up the sleeping worker. */ apr_thread_mutex_lock(worker->mutex); - apr_thread_mutex_unlock(worker->mutex); + worker->csd = (apr_socket_t *)csd; + /* We must own the lock associated with the condition + * variable that we are signaling. */ apr_thread_cond_signal(worker->cond); + apr_thread_mutex_unlock(worker->mutex); worker = NULL; } } @@ -962,8 +965,10 @@ static void *listener_thread(apr_thread_t *thd, void * dummy) worker_stack_interrupt_all(idle_worker_stack); if (worker) { apr_thread_mutex_lock(worker->mutex); - apr_thread_mutex_unlock(worker->mutex); + /* We must own the lock associated with the condition + * variable that we are signaling. */ apr_thread_cond_signal(worker->cond); + apr_thread_mutex_unlock(worker->mutex); } dying = 1; ap_scoreboard_image->parent[process_slot].quiescing = 1; @@ -1003,6 +1008,8 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy) apr_pool_create_ex(&ptrans, NULL, NULL, allocator); apr_allocator_set_owner(allocator, ptrans); + /* XXX: What happens if this is allocated from the + * single-thread-optimized ptrans pool? -aaron */ bucket_alloc = apr_bucket_alloc_create(tpool); wakeup = (worker_wakeup_info *)apr_palloc(tpool, sizeof(*wakeup)); -- 2.40.0