apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1001686 - /apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c
Date Mon, 27 Sep 2010 11:58:41 GMT
Author: trawick
Date: Mon Sep 27 11:58:40 2010
New Revision: 1001686

URL: http://svn.apache.org/viewvc?rev=1001686&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.5.x/misc/apr_thread_pool.c

Modified: apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c?rev=1001686&r1=1001685&r2=1001686&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c (original)
+++ apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c Mon Sep 27 11:58:40 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;
         }



Mime
View raw message