apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r168115 - in /apr/apr/trunk: include/apr_pools.h memory/unix/apr_pools.c
Date Wed, 04 May 2005 11:30:27 GMT
Author: jorton
Date: Wed May  4 04:30:27 2005
New Revision: 168115

URL: http://svn.apache.org/viewcvs?rev=168115&view=rev
Log:
Steal the joined-pool debug code from 1.3:

* include/apr_pools.h (apr_pool_is_ancestor): Note special semantics
for joined pools.

* memory/unix/apr_pools.c (apr_pool_join): Implement.
(apr_pool_is_ancestor): Adjust for joined pools.

Modified:
    apr/apr/trunk/include/apr_pools.h
    apr/apr/trunk/memory/unix/apr_pools.c

Modified: apr/apr/trunk/include/apr_pools.h
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/include/apr_pools.h?rev=168115&r1=168114&r2=168115&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_pools.h (original)
+++ apr/apr/trunk/include/apr_pools.h Wed May  4 04:30:27 2005
@@ -392,11 +392,15 @@
 APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);
 
 /**
- * Determine if pool a is an ancestor of pool b
+ * Determine if pool a is an ancestor of pool b.
  * @param a The pool to search
  * @param b The pool to search for
  * @return True if a is an ancestor of b, NULL is considered an ancestor
  *         of all pools.
+ * @remark if compiled with APR_POOL_DEBUG, this function will also
+ * return true if A is a pool which has been guaranteed by the caller
+ * (using apr_pool_join) to have a lifetime at least as long as some
+ * ancestor of pool B.
  */
 APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);
 

Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/memory/unix/apr_pools.c?rev=168115&r1=168114&r2=168115&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Wed May  4 04:30:27 2005
@@ -456,6 +456,8 @@
     char                 *self_first_avail;
 
 #else /* APR_POOL_DEBUG */
+    apr_pool_t           *joined; /* the caller has guaranteed that this pool
+                                   * will survive as long as ->joined */
     debug_node_t         *nodes;
     const char           *file_line;
     apr_uint32_t          creation_flags;
@@ -1655,6 +1657,12 @@
 
 APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub)
 {
+#if APR_POOL_DEBUG
+    if (sub->parent != p) {
+        abort();
+    }
+    sub->joined = p;
+#endif
 }
 
 static int pool_find(apr_pool_t *pool, void *data)
@@ -1804,6 +1812,14 @@
 {
     if (a == NULL)
         return 1;
+
+#if APR_POOL_DEBUG
+    /* Find the pool with the longest lifetime guaranteed by the
+     * caller: */
+    while (a->joined) {
+        a = a->joined;
+    }
+#endif
 
     while (b) {
         if (a == b)



Mime
View raw message