apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1460184 - /apr/apr/trunk/memory/unix/apr_pools.c
Date Sat, 23 Mar 2013 16:18:08 GMT
Author: sf
Date: Sat Mar 23 16:18:08 2013
New Revision: 1460184

URL: http://svn.apache.org/r1460184
Log:
Split apr_pool_check_integrity() into two parts

Run the pool owner check part only after pre-cleanups have been run, in
order to give them a chance to kill of any threads that may still be
accessing the pool.

Modified:
    apr/apr/trunk/memory/unix/apr_pools.c

Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=1460184&r1=1460183&r2=1460184&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Sat Mar 23 16:18:08 2013
@@ -1436,7 +1436,7 @@ static int apr_pool_is_child_of(apr_pool
 }
 #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */
 
-static void apr_pool_check_integrity(apr_pool_t *pool)
+static void apr_pool_check_lifetime(apr_pool_t *pool)
 {
     /* Rule of thumb: use of the global pool is always
      * ok, since the only user is apr_pools.c.  Unless
@@ -1460,7 +1460,10 @@ static void apr_pool_check_integrity(apr
         abort();
     }
 #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */
+}
 
+static void apr_pool_check_owner(apr_pool_t *pool)
+{
 #if (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER)
 #if APR_HAS_THREADS
     if (!apr_os_thread_equal(pool->owner, apr_os_thread_current())) {
@@ -1474,6 +1477,12 @@ static void apr_pool_check_integrity(apr
 #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER) */
 }
 
+static void apr_pool_check_integrity(apr_pool_t *pool)
+{
+    apr_pool_check_lifetime(pool);
+    apr_pool_check_owner(pool);
+}
+
 APR_DECLARE(void) apr_pool_owner_set(apr_pool_t *pool, apr_uint32_t flags)
 {
 #if APR_HAS_THREADS && (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER)
@@ -1668,6 +1677,12 @@ static void pool_clear_debug(apr_pool_t 
     run_cleanups(&pool->pre_cleanups);
     pool->pre_cleanups = NULL;
 
+    /*
+     * Now that we have given the pre cleanups the chance to kill of any
+     * threads using the pool, the owner must be correct.
+     */
+    apr_pool_check_owner(pool);
+
     /* Destroy the subpools.  The subpools will detach themselves from
      * this pool thus this loop is safe and easy.
      */
@@ -1716,7 +1731,7 @@ APR_DECLARE(void) apr_pool_clear_debug(a
     apr_thread_mutex_t *mutex = NULL;
 #endif
 
-    apr_pool_check_integrity(pool);
+    apr_pool_check_lifetime(pool);
 
 #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE)
     apr_pool_log_event(pool, "CLEAR", file_line, 1);
@@ -1754,7 +1769,7 @@ APR_DECLARE(void) apr_pool_clear_debug(a
 
 static void pool_destroy_debug(apr_pool_t *pool, const char *file_line)
 {
-    apr_pool_check_integrity(pool);
+    apr_pool_check_lifetime(pool);
 
 #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE)
     apr_pool_log_event(pool, "DESTROY", file_line, 1);



Mime
View raw message