summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-05-31 11:42:40 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-05-31 11:42:40 +0000
commit61422bf58606512845ee1b4ba8da46cb76cc2b5f (patch)
treeda103823c066a6134533bb9344caf3f5e10059eb
parent44d1fac7ce237829ca7274bddf3fe6d28c8ec695 (diff)
downloadlibapr-61422bf58606512845ee1b4ba8da46cb76cc2b5f.tar.gz
Abort if the caller violates a joined-pool guarantee and explicitly
destroys a joined pool: (catches the mod_include pool lifetime issues described in PR 12655) * memory/unix/apr_pools.c (pool_destroy_debug): Renamed from apr_pool_destroy_debug; made static. (apr_pool_destroy_debug): New function, wrapper for pool_destroy_debug; abort if called on a joined pool. (pool_clear_debug): Use pool_destroy_debug rather than the wrapper to destroy subpools. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@179208 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--memory/unix/apr_pools.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index 623813551..335516fd5 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -500,6 +500,9 @@ static void run_cleanups(cleanup_t **c);
static void run_child_cleanups(cleanup_t **c);
static void free_proc_chain(struct process_chain *procs);
+#if APR_POOL_DEBUG
+static void pool_destroy_debug(apr_pool_t *pool, const char *file_line);
+#endif
#if !APR_POOL_DEBUG
/*
@@ -1361,7 +1364,7 @@ static void pool_clear_debug(apr_pool_t *pool, const char *file_line)
* this pool thus this loop is safe and easy.
*/
while (pool->child)
- apr_pool_destroy_debug(pool->child, file_line);
+ pool_destroy_debug(pool->child, file_line);
/* Run cleanups */
run_cleanups(&pool->cleanups);
@@ -1436,8 +1439,7 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool,
#endif /* APR_HAS_THREADS */
}
-APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool,
- const char *file_line)
+static void pool_destroy_debug(apr_pool_t *pool, const char *file_line)
{
apr_pool_check_integrity(pool);
@@ -1474,6 +1476,22 @@ APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool,
free(pool);
}
+APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool,
+ const char *file_line)
+{
+ if (pool->joined) {
+ /* Joined pools must not be explicitly destroyed; the caller
+ * has broken the guarantee. */
+#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
+ apr_pool_log_event(pool, "LIFE",
+ __FILE__ ":apr_pool_destroy abort on joined", 0);
+#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
+
+ abort();
+ }
+ pool_destroy_debug(pool, file_line);
+}
+
APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
apr_pool_t *parent,
apr_abortfunc_t abort_fn,