diff options
author | sf <sf@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-22 20:10:42 +0000 |
---|---|---|
committer | sf <sf@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-22 20:10:42 +0000 |
commit | c9753627c9169e252cc56e0375a69531acc414cd (patch) | |
tree | 33af3c9619eb4d7e93ddc27dd3e6745437d61997 /util-misc | |
parent | 102946fa6677c2eb7443a9ed8030d361c5bdcc67 (diff) | |
download | libapr-c9753627c9169e252cc56e0375a69531acc414cd.tar.gz |
Fix thread unsafe pool usage. This is a potential culprit for the occasional
testreslist failures.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1126207 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'util-misc')
-rw-r--r-- | util-misc/apr_thread_pool.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util-misc/apr_thread_pool.c b/util-misc/apr_thread_pool.c index 9ec046077..006370bae 100644 --- a/util-misc/apr_thread_pool.c +++ b/util-misc/apr_thread_pool.c @@ -353,13 +353,18 @@ APR_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me, *me = NULL; tp = apr_pcalloc(pool, sizeof(apr_thread_pool_t)); - tp->pool = pool; - + /* + * This pool will be used by different threads. As we cannot ensure that + * our caller won't use the pool without acquiring the mutex, we must + * create a new sub pool. + */ + rv = apr_pool_create(&tp->pool, pool); + if (APR_SUCCESS != rv) + return rv; rv = thread_pool_construct(tp, init_threads, max_threads); - if (APR_SUCCESS != rv) { + if (APR_SUCCESS != rv) return rv; - } - apr_pool_cleanup_register(pool, tp, thread_pool_cleanup, + apr_pool_cleanup_register(tp->pool, tp, thread_pool_cleanup, apr_pool_cleanup_null); while (init_threads) { |