diff options
author | Yann Ylavic <ylavic@apache.org> | 2022-01-18 17:43:10 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2022-01-18 17:43:10 +0000 |
commit | 7a52a7c060ebb42f6e83505755b49bc1e1acd183 (patch) | |
tree | acd476b370e292dce6ef1ef8f22690d99315ac4d /memory/unix/apr_pools.c | |
parent | 84651d9f47a2ec0ba2f3921a79683540ecf98029 (diff) | |
download | apr-7a52a7c060ebb42f6e83505755b49bc1e1acd183.tar.gz |
apr_thread: Follow up to r1884078: Unmanaged pools for attached threads too.
r1884078 fixed lifetime issues with detached threads by using unmanaged pool
destroyed by the thread itself on exit, with no binding to the parent pool.
This commit makes use of unmanaged pools for attached threads too, they needed
their own allocator anyway due to apr_thread_detach() being callable anytime
later. apr__pool_unmanage() was a hack to detach a subpool from its parent, but
if a subpool needs its own allocator for this to work correctly there is no
point in creating a subpool for threads (no memory reuse on destroy for short
living threads for instance).
Since an attached thread has its own lifetime now, apr_thread_join() must be
called to free its resources/pool, though it's no different than before when
destroying the parent pool was UB if the thread was still running (i.e. not
joined yet).
Let's acknoledge that threads want no binding with the pool passed to them at
creation time, besides the abort_fn which they can steal :)
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897179 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory/unix/apr_pools.c')
-rw-r--r-- | memory/unix/apr_pools.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index b280547e4..07012ae3a 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -2343,46 +2343,6 @@ APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag) #endif /* !APR_POOL_DEBUG */ -apr_status_t apr__pool_unmanage(apr_pool_t *pool); - -/* For APR internal use only (for now). - * Detach the pool from its/any parent (i.e. un-manage). - */ -apr_status_t apr__pool_unmanage(apr_pool_t *pool) -{ - apr_pool_t *parent = pool->parent; - - if (!parent) { - return APR_NOTFOUND; - } - -#if APR_POOL_DEBUG - if (pool->allocator && pool->allocator == parent->allocator) { - return APR_EINVAL; - } - apr_thread_mutex_lock(parent->mutex); -#else - if (pool->allocator == parent->allocator) { - return APR_EINVAL; - } - allocator_lock(parent->allocator); -#endif - - /* Remove the pool from the parent's children */ - if ((*pool->ref = pool->sibling) != NULL) { - pool->sibling->ref = pool->ref; - } - pool->parent = NULL; - -#if APR_POOL_DEBUG - apr_thread_mutex_unlock(parent->mutex); -#else - allocator_unlock(parent->allocator); -#endif - - return APR_SUCCESS; -} - #ifdef NETWARE void netware_pool_proc_cleanup () { |