summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2008-10-30 10:45:44 +0000
committerpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2008-10-30 10:45:44 +0000
commitd77ee21af4a797d65e6758c8a3d9a4d0f557b814 (patch)
tree231705dcb669e4bbc6f7c781c3894cb338bf446e
parenteaaf88eed137e94a13702ef9d0fcad2096786892 (diff)
downloadlibapr-util-d77ee21af4a797d65e6758c8a3d9a4d0f557b814.tar.gz
* misc/apr_thread_pool.c
(apr_thread_pool_create): Only set the output variable if we were successful. git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@709135 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--misc/apr_thread_pool.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/misc/apr_thread_pool.c b/misc/apr_thread_pool.c
index 0cbdd2df..693518d1 100644
--- a/misc/apr_thread_pool.c
+++ b/misc/apr_thread_pool.c
@@ -362,33 +362,36 @@ APU_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me,
{
apr_thread_t *t;
apr_status_t rv = APR_SUCCESS;
+ apr_thread_pool_t *tp;
- *me = apr_pcalloc(pool, sizeof(**me));
- if (!*me) {
- return APR_ENOMEM;
- }
+ *me = NULL;
+ tp = apr_pcalloc(pool, sizeof(apr_thread_pool_t));
- (*me)->pool = pool;
+ tp->pool = pool;
- rv = thread_pool_construct(*me, init_threads, max_threads);
+ rv = thread_pool_construct(tp, init_threads, max_threads);
if (APR_SUCCESS != rv) {
- *me = NULL;
return rv;
}
- apr_pool_cleanup_register(pool, *me, thread_pool_cleanup,
+ apr_pool_cleanup_register(pool, tp, thread_pool_cleanup,
apr_pool_cleanup_null);
while (init_threads) {
- rv = apr_thread_create(&t, NULL, thread_pool_func, *me, (*me)->pool);
+ rv = apr_thread_create(&t, NULL, thread_pool_func, tp, tp->pool);
if (APR_SUCCESS != rv) {
break;
}
- ++(*me)->thd_cnt;
- if ((*me)->thd_cnt > (*me)->thd_high)
- (*me)->thd_high = (*me)->thd_cnt;
+ tp->thd_cnt++;
+ if (tp->thd_cnt > tp->thd_high) {
+ tp->thd_high = tp->thd_cnt;
+ }
--init_threads;
}
+ if (rv == APR_SUCCESS) {
+ *me = tp;
+ }
+
return rv;
}