summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2022-10-20 14:55:25 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2022-10-20 14:55:25 +0000
commitaf17fa54e2fa116f51acec471e819a17b1303498 (patch)
treef8863f2f8cfaca3c942db5f53bd0180c1aa0ab51
parentd36f1c0de638fce29655834159e38b2055c75b7f (diff)
downloadlibapr-util-af17fa54e2fa116f51acec471e819a17b1303498.tar.gz
apr_thread_pool: stop the threads before destroying the thread_pool's pool.
With APR <= 1.7 the threads' pools are children of the thread_pool's pool and APR_POOL_DEBUG would deadlock if thread_pool_cleanup() is called while the thread_pool's pool is destroyed (because of parent locking). With APR > 1.7 the threads' pools are unmanaged so there is no such issue, yet it does not hurt to stop the threads before. * misc/apr_thread_pool.c(apr_thread_pool_destroy): Explicitely run the cleanup (which stops the threads) before destroying the thread_pool's pool. Note: this is APR-util material only since APR trunk does not have the issue (per above). Merges r1904743 from ^/apr/apr-util/branches/1.7.x. git-svn-id: https://svn.apache.org/repos/asf/apr/apr-util/branches/1.6.x@1904744 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--misc/apr_thread_pool.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/misc/apr_thread_pool.c b/misc/apr_thread_pool.c
index 6e36ea78..5aa3b65a 100644
--- a/misc/apr_thread_pool.c
+++ b/misc/apr_thread_pool.c
@@ -452,6 +452,14 @@ APU_DECLARE(apr_status_t) apr_thread_pool_create(apr_thread_pool_t ** me,
APU_DECLARE(apr_status_t) apr_thread_pool_destroy(apr_thread_pool_t * me)
{
+ /* Stop the threads before destroying me->pool: with APR <= 1.7 the
+ * threads' pools are children of me->pool and APR_POOL_DEBUG would
+ * deadlock if thread_pool_cleanup() is called while me->pool is
+ * destroyed (because of parent locking).
+ * With APR > 1.7 the threads' pools are unmanaged so there is no
+ * such issue, yet it does not hurt to stop the threads before.
+ */
+ apr_pool_cleanup_run(me->pool, me, thread_pool_cleanup);
apr_pool_destroy(me->pool);
return APR_SUCCESS;
}