summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormturk <mturk@13f79535-47bb-0310-9956-ffa450edef68>2008-08-07 06:57:38 +0000
committermturk <mturk@13f79535-47bb-0310-9956-ffa450edef68>2008-08-07 06:57:38 +0000
commit83226211d44becad3909ce6895cfc42222fed05b (patch)
treecdc7cc932ca4485c3e4b8aa2f5a6b05ceca57dfa
parent8ec477d5f39aaf4afca7d7040e7cb3ec074064d8 (diff)
downloadlibapr-util-83226211d44becad3909ce6895cfc42222fed05b.tar.gz
Add API that allows to setup the cleanup order after the reslist was created
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@683526 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/apr_reslist.h20
-rw-r--r--misc/apr_reslist.c11
2 files changed, 31 insertions, 0 deletions
diff --git a/include/apr_reslist.h b/include/apr_reslist.h
index 70037b69..ad27d80c 100644
--- a/include/apr_reslist.h
+++ b/include/apr_reslist.h
@@ -59,6 +59,10 @@ typedef apr_status_t (*apr_reslist_constructor)(void **resource, void *params,
typedef apr_status_t (*apr_reslist_destructor)(void *resource, void *params,
apr_pool_t *pool);
+/* Cleanup order modes */
+#define APR_RESLIST_CLEANUP_DEFAULT 0 /**< default pool cleanup */
+#define APR_RESLIST_CLEANUP_FIRST 1 /**< use pool pre cleanup */
+
/**
* Create a new resource list with the following parameters:
* @param reslist An address where the pointer to the new resource
@@ -145,6 +149,22 @@ APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist,
*/
APU_DECLARE(apr_status_t) apr_reslist_maintain(apr_reslist_t *reslist);
+/**
+ * Set reslist cleanup order.
+ * @param reslist The resource list.
+ * @param mode Cleanup order mode
+ * <PRE>
+ * APR_RESLIST_CLEANUP_DEFAULT default pool cleanup order
+ * APR_RESLIST_CLEANUP_FIRST use pool pre cleanup
+ * </PRE>
+ * @remark If APR_RESLIST_CLEANUP_FIRST is used the destructors will
+ * be called before child pools of the pool used to create the reslist
+ * are destroyed. This allows to explicitly destroy the child pools
+ * inside reslist destructors.
+ */
+APU_DECLARE(void) apr_reslist_cleanup_order_set(apr_reslist_t *reslist,
+ apr_uint32_t mode);
+
#ifdef __cplusplus
}
#endif
diff --git a/misc/apr_reslist.c b/misc/apr_reslist.c
index 3b6d630a..0c43e074 100644
--- a/misc/apr_reslist.c
+++ b/misc/apr_reslist.c
@@ -460,3 +460,14 @@ APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist,
#endif
return ret;
}
+
+APU_DECLARE(void) apr_reslist_cleanup_order_set(apr_reslist_t *rl,
+ apr_uint32_t mode)
+{
+ apr_pool_cleanup_kill(rl->pool, rl, reslist_cleanup);
+ if (mode == APR_RESLIST_CLEANUP_FIRST)
+ apr_pool_pre_cleanup_register(rl->pool, rl, reslist_cleanup);
+ else
+ apr_pool_cleanup_register(rl->pool, rl, reslist_cleanup,
+ apr_pool_cleanup_null);
+}