apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r683526 - in /apr/apr-util/trunk: include/apr_reslist.h misc/apr_reslist.c
Date Thu, 07 Aug 2008 06:57:39 GMT
Author: mturk
Date: Wed Aug  6 23:57:38 2008
New Revision: 683526

URL: http://svn.apache.org/viewvc?rev=683526&view=rev
Log:
Add API that allows to setup the cleanup order after the reslist was created

Modified:
    apr/apr-util/trunk/include/apr_reslist.h
    apr/apr-util/trunk/misc/apr_reslist.c

Modified: apr/apr-util/trunk/include/apr_reslist.h
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apr_reslist.h?rev=683526&r1=683525&r2=683526&view=diff
==============================================================================
--- apr/apr-util/trunk/include/apr_reslist.h (original)
+++ apr/apr-util/trunk/include/apr_reslist.h Wed Aug  6 23:57:38 2008
@@ -59,6 +59,10 @@
 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_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

Modified: apr/apr-util/trunk/misc/apr_reslist.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/misc/apr_reslist.c?rev=683526&r1=683525&r2=683526&view=diff
==============================================================================
--- apr/apr-util/trunk/misc/apr_reslist.c (original)
+++ apr/apr-util/trunk/misc/apr_reslist.c Wed Aug  6 23:57:38 2008
@@ -460,3 +460,14 @@
 #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);
+}



Mime
View raw message