You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2005/05/04 13:30:27 UTC
svn commit: r168115 - in /apr/apr/trunk: include/apr_pools.h
memory/unix/apr_pools.c
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)
Re: apr_pool_join, WAS: Re: svn commit: r168115 - in /apr/apr/trunk: include/apr_pools.h memory/unix/apr_pools.c
Posted by Joe Orton <jo...@redhat.com>.
On Wed, May 04, 2005 at 02:08:43PM +0200, Sander Striker wrote:
> jorton@apache.org wrote:
> >--- 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);
>
> I'd rather see a new function for this. apr_pool_will_outlive()?
> apr_pool_outlives()?
> Naming isn't my strong part. Anyways, I'd like to see ancestor mean
> ancestor and not something else. Mostly because ancestry is not only about
> lifetimes but about hierarchy as well.
I thought about that that too, but since this is exactly how all
existing uses of pool-joining/ancestry *expect* the function to behave,
I think it should really keep the name. It also matches up with the
commentary of pool lifetime issues in apr_pools.h.
Regards,
joe
apr_pool_join, WAS: Re: svn commit: r168115 - in /apr/apr/trunk:
include/apr_pools.h memory/unix/apr_pools.c
Posted by Sander Striker <st...@apache.org>.
jorton@apache.org wrote:
> 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);
I'd rather see a new function for this. apr_pool_will_outlive()? apr_pool_outlives()?
Naming isn't my strong part. Anyways, I'd like to see ancestor mean
ancestor and not something else. Mostly because ancestry is not only about
lifetimes but about hierarchy as well.
Other than that: +1.
Sander