diff options
author | Stefan Fritsch <sf@sfritsch.de> | 2012-01-29 13:30:57 +0100 |
---|---|---|
committer | Stefan Fritsch <sf@sfritsch.de> | 2012-01-29 13:30:57 +0100 |
commit | d1d018768afd79cb2ecd1805f0d8f3ed23f4076b (patch) | |
tree | 04d53b0a9786234f3bbd3badffdb22dbe2b74d03 /srclib/apr-util/misc/apr_thread_pool.c | |
parent | 0890390c00801651d08d3794e13b31a5dabbf5ef (diff) | |
download | apache2-upstream/2.2.22.tar.gz |
Upstream tarball 2.2.22upstream/2.2.22
Diffstat (limited to 'srclib/apr-util/misc/apr_thread_pool.c')
-rw-r--r-- | srclib/apr-util/misc/apr_thread_pool.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/srclib/apr-util/misc/apr_thread_pool.c b/srclib/apr-util/misc/apr_thread_pool.c index a53973f1..01c2e21d 100644 --- a/srclib/apr-util/misc/apr_thread_pool.c +++ b/srclib/apr-util/misc/apr_thread_pool.c @@ -237,7 +237,6 @@ static struct apr_thread_list_elt *elt_new(apr_thread_pool_t * me, */ static void *APR_THREAD_FUNC thread_pool_func(apr_thread_t * t, void *param) { - apr_status_t rv = APR_SUCCESS; apr_thread_pool_t *me = param; apr_thread_pool_task_t *task = NULL; apr_interval_time_t wait; @@ -313,10 +312,10 @@ static void *APR_THREAD_FUNC thread_pool_func(apr_thread_t * t, void *param) wait = -1; if (wait >= 0) { - rv = apr_thread_cond_timedwait(me->cond, me->lock, wait); + apr_thread_cond_timedwait(me->cond, me->lock, wait); } else { - rv = apr_thread_cond_wait(me->cond, me->lock); + apr_thread_cond_wait(me->cond, me->lock); } } @@ -353,13 +352,18 @@ APU_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) { |