apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1001685 - /apr/apr/trunk/util-misc/apr_thread_pool.c
Date Mon, 27 Sep 2010 11:57:17 GMT
Author: trawick
Date: Mon Sep 27 11:57:17 2010
New Revision: 1001685

URL: http://svn.apache.org/viewvc?rev=1001685&view=rev
Log:
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/trunk/util-misc/apr_thread_pool.c

Modified: apr/apr/trunk/util-misc/apr_thread_pool.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/util-misc/apr_thread_pool.c?rev=1001685&r1=1001684&r2=1001685&view=diff
==============================================================================
--- apr/apr/trunk/util-misc/apr_thread_pool.c (original)
+++ apr/apr/trunk/util-misc/apr_thread_pool.c Mon Sep 27 11:57:17 2010
@@ -377,7 +377,13 @@ APR_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