summaryrefslogtreecommitdiff
path: root/util-misc
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2010-09-27 11:57:17 +0000
committerJeff Trawick <trawick@apache.org>2010-09-27 11:57:17 +0000
commita06fce846a070e94c2ae2cb4f3ca6c303da27b29 (patch)
tree13bac13f69844ec9a17a7310b1c0df30183aee15 /util-misc
parentbe0c2309df4a979bba9133b2ac6fd46f107eea73 (diff)
downloadapr-a06fce846a070e94c2ae2cb4f3ca6c303da27b29.tar.gz
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 <akorobka fxcm.com> Reviewed by: trawick git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1001685 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util-misc')
-rw-r--r--util-misc/apr_thread_pool.c6
1 files changed, 6 insertions, 0 deletions
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;
}