apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1358141 - in /apr/apr-util/branches/1.5.x: ./ misc/apr_thread_pool.c
Date Fri, 06 Jul 2012 11:45:46 GMT
Author: sf
Date: Fri Jul  6 11:45:45 2012
New Revision: 1358141

URL: http://svn.apache.org/viewvc?rev=1358141&view=rev
Log:
Backport r1126207 from trunk:
    
    Fix thread unsafe pool usage. This is a potential culprit for the
    occasional testreslist failures.
 

Modified:
    apr/apr-util/branches/1.5.x/   (props changed)
    apr/apr-util/branches/1.5.x/misc/apr_thread_pool.c

Propchange: apr/apr-util/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr-util/branches/1.4.x:r1126217

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=1358141&r1=1358140&r2=1358141&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 Fri Jul  6 11:45:45 2012
@@ -352,13 +352,18 @@ APU_DECLARE(apr_status_t) apr_thread_poo
     *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) {



Mime
View raw message