]> granicus.if.org Git - apache/commitdiff
Fixed a race condition
authorBrian Pane <brianp@apache.org>
Sun, 14 Apr 2002 00:31:43 +0000 (00:31 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 14 Apr 2002 00:31:43 +0000 (00:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94640 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/experimental/leader/leader.c

index 966b7717ff41b599331bc92bde057f62a37339e7..49f424d581b9f4a07f3cfea78717e05d938c55bf 100644 (file)
@@ -321,6 +321,16 @@ static apr_status_t worker_stack_awaken_next(worker_stack *stack)
         if ((rv = apr_thread_mutex_unlock(stack->mutex)) != APR_SUCCESS) {
             return rv;
         }
+        /* Acquire and release the idle worker's mutex to ensure
+         * that it's actually waiting on its condition variable
+         */
+        if ((rv = apr_thread_mutex_lock(wakeup->mutex)) != APR_SUCCESS) {
+            return rv;
+        }
+        if ((rv = apr_thread_mutex_unlock(wakeup->mutex)) != APR_SUCCESS) {
+            return rv;
+        }
+        apr_thread_mutex_unlock(wakeup->mutex);
         if ((rv = apr_thread_cond_signal(wakeup->cond)) != APR_SUCCESS) {
             apr_thread_mutex_unlock(stack->mutex);
             return rv;