diff options
author | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2019-07-17 11:41:21 +0000 |
---|---|---|
committer | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2019-07-17 11:41:21 +0000 |
commit | 568bbacf17a0c7929abf548b368f4bcb8be10faf (patch) | |
tree | 03e39170652c17a075244270864b533ec7238e4b | |
parent | f14314a8b6e8a29331da528678fd01942eb52e20 (diff) | |
download | libapr-568bbacf17a0c7929abf548b368f4bcb8be10faf.tar.gz |
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.
Backport of r1460184 from trunk resp. r1863199 from 1.7.x.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1863208 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | memory/unix/apr_pools.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 3361f7a7d..614919ede 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -1594,7 +1594,7 @@ static int apr_pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent) } #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 @@ -1618,7 +1618,10 @@ static void apr_pool_check_integrity(apr_pool_t *pool) 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())) { @@ -1632,6 +1635,11 @@ static void apr_pool_check_integrity(apr_pool_t *pool) #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); +} /* * Initialization (debug) @@ -1820,6 +1828,12 @@ static void pool_clear_debug(apr_pool_t *pool, const char *file_line) 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. */ @@ -1868,7 +1882,7 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, 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); @@ -1906,7 +1920,7 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool, 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); |