diff options
author | Stefan Fritsch <sf@apache.org> | 2011-05-22 20:10:42 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2011-05-22 20:10:42 +0000 |
commit | 5b582e33680434599d0479ce9bf7a585b5403b1a (patch) | |
tree | 33af3c9619eb4d7e93ddc27dd3e6745437d61997 /util-misc | |
parent | c78eee25439f502d30ca5a5bf8244990f264016d (diff) | |
download | apr-5b582e33680434599d0479ce9bf7a585b5403b1a.tar.gz |
Fix thread unsafe pool usage. This is a potential culprit for the occasional
testreslist failures.
git-svn-id: https://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) { |