summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>1999-10-12 17:54:32 +0000
committerRyan Bloom <rbb@apache.org>1999-10-12 17:54:32 +0000
commit626490ae49c978c1bf2352104003df17b73ff45d (patch)
tree8e2e8ae8b53e2f289f99f32245f42619f1748177 /memory
parent6824aef3fd5fcbb6ec41ddbcef9691ac87ac115c (diff)
downloadapr-626490ae49c978c1bf2352104003df17b73ff45d.tar.gz
Fix a bug in pool locking. The current logic requires recursive mutex's,
which are non-portable. This fix ensures that when clearing and destroying pools, we only try to grab the mutex once. The fact that APR locks are not recursive will be documented in a later commit. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@59329 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r--memory/unix/apr_pools.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index ceced1d2a..0a6c39a2f 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -557,15 +557,25 @@ ap_pool_t *ap_init_alloc(void)
void ap_destroy_real_pool(ap_pool_t *);
-static void ap_clear_real_pool(ap_pool_t *a)
+/* We only want to lock the mutex if we are being called from ap_clear_pool.
+ * This is because if we also call this function from ap_destroy_real_pool,
+ * which also locks the same mutex, and recursive locks aren't portable.
+ * This way, we are garaunteed that we only lock this mutex once when calling
+ * either one of these functions.
+ */
+static void ap_clear_real_pool(ap_pool_t *a, int clearcaller)
{
ap_block_alarms();
- ap_lock(alloc_mutex);
+ if (clearcaller) {
+ ap_lock(alloc_mutex);
+ }
while (a->sub_pools) {
ap_destroy_real_pool(a->sub_pools);
}
- ap_unlock(alloc_mutex);
+ if (clearcaller) {
+ ap_unlock(alloc_mutex);
+ }
/*
* Don't hold the mutex during cleanups.
*/
@@ -598,13 +608,13 @@ static void ap_clear_real_pool(ap_pool_t *a)
API_EXPORT(void) ap_clear_pool(struct context_t *a)
{
- ap_clear_real_pool(a->pool);
+ ap_clear_real_pool(a->pool, 1);
}
API_EXPORT(void) ap_destroy_real_pool(ap_pool_t *a)
{
ap_block_alarms();
- ap_clear_real_pool(a);
+ ap_clear_real_pool(a, 0);
ap_lock(alloc_mutex);
if (a->parent) {