summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2022-10-20 14:53:34 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2022-10-20 14:53:34 +0000
commit8a9f2f4df8fd6d69b2a77cf75dfbe899e1c46b6d (patch)
tree7cb3c29b9d63a06f4feb911d1f63aa651f48913c
parentef11d57aa6356a0656da4f7d986097efd0a3c861 (diff)
downloadlibapr-util-8a9f2f4df8fd6d69b2a77cf75dfbe899e1c46b6d.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). git-svn-id: https://svn.apache.org/repos/asf/apr/apr-util/branches/1.7.x@1904743 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;
}