You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2010/09/27 13:59:12 UTC
svn commit: r1001687 - /apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c
Author: trawick
Date: Mon Sep 27 11:59:12 2010
New Revision: 1001687
URL: http://svn.apache.org/viewvc?rev=1001687&view=rev
Log:
merge r1001685 from apr trunk:
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
Modified:
apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c
Modified: apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c?rev=1001687&r1=1001686&r2=1001687&view=diff
==============================================================================
--- apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c (original)
+++ apr/apr-util/branches/1.4.x/misc/apr_thread_pool.c Mon Sep 27 11:59:12 2010
@@ -377,7 +377,13 @@ APU_DECLARE(apr_status_t) apr_thread_poo
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;
}