summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authorstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2002-01-14 12:13:53 +0000
committerstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2002-01-14 12:13:53 +0000
commit75cacc98d083edc27470c8b21e44528652d7b616 (patch)
treeb9bbd87c240b7dae974464b4de03f5f09e85b9a4 /memory
parent42b3c4d2f0ccda3384db042a69c6624f9cea5024 (diff)
downloadlibapr-75cacc98d083edc27470c8b21e44528652d7b616.tar.gz
Fix for the simple stats in debug mode. This was the same problem as
with the integrity check; we were traversing the hierarchy without doing proper locking. Now we are. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'memory')
-rw-r--r--memory/unix/apr_pools.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index 0323129d9..02e8de457 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -1388,23 +1388,60 @@ static apr_size_t pool_num_bytes(apr_pool_t *pool)
return size;
}
-APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse)
+#if APR_HAS_THREADS
+static apr_size_t pool_num_bytes_recursive(apr_pool_t *pool,
+ apr_thread_mutex_t *mutex)
{
apr_size_t size;
+ apr_pool_t *child;
size = pool_num_bytes(pool);
- if (recurse) {
- pool = pool->child;
-
- while (pool) {
- size += apr_pool_num_bytes(pool, 1);
+ if (pool->mutex && pool->mutex != mutex) {
+ apr_thread_mutex_lock(pool->mutex);
+ }
- pool = pool->sibling;
- }
+ child = pool->child;
+ while (child) {
+ size += pool_num_bytes_recursive(child, pool->mutex);
+
+ child = child->sibling;
+ }
+
+ if (pool->mutex && pool->mutex != mutex) {
+ apr_thread_mutex_unlock(pool->mutex);
+ }
+
+ return size;
+}
+#else
+static apr_size_t pool_num_bytes_recursive(apr_pool_t *pool)
+{
+ apr_size_t size;
+
+ size = pool_num_bytes(pool);
+
+ pool = pool->child;
+ while (pool) {
+ size += pool_num_bytes_recursive(pool);
+
+ pool = pool->sibling;
}
return size;
+}
+#endif
+
+APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse)
+{
+ if (!recurse)
+ return pool_num_bytes(pool);
+
+#if APR_HAS_THREADS
+ return pool_num_bytes_recursive(pool, pool->mutex);
+#else
+ return pool_num_bytes_recursive(pool);
+#endif
}
APR_DECLARE(apr_size_t) apr_pool_free_blocks_num_bytes(void)