From a06fce846a070e94c2ae2cb4f3ca6c303da27b29 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 27 Sep 2010 11:57:17 +0000 Subject: apr_thread_pool_create: Fix pool corruption caused by multithread use of the pool when multiple initial threads are created. PR: 47843 Submitted by: Alex Korobka Reviewed by: trawick git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1001685 13f79535-47bb-0310-9956-ffa450edef68 --- util-misc/apr_thread_pool.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util-misc') diff --git a/util-misc/apr_thread_pool.c b/util-misc/apr_thread_pool.c index 39d933055..6b03492cc 100644 --- a/util-misc/apr_thread_pool.c +++ b/util-misc/apr_thread_pool.c @@ -377,7 +377,13 @@ APR_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me, apr_pool_cleanup_null); while (init_threads) { + /* Grab the mutex as apr_thread_create() and thread_pool_func() will + * allocate from (*me)->pool. This is dangerous if there are multiple + * initial threads to create. + */ + apr_thread_mutex_lock(tp->lock); rv = apr_thread_create(&t, NULL, thread_pool_func, tp, tp->pool); + apr_thread_mutex_unlock(tp->lock); if (APR_SUCCESS != rv) { break; } -- cgit v1.2.1