apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stri...@apache.org
Subject cvs commit: apr/memory/unix apr_pools.c
Date Mon, 14 Jan 2002 09:18:41 GMT
striker     02/01/14 01:18:41

  Modified:    memory/unix apr_pools.c
  Log:
  Fix the lifetime checking by locking the childlist before
  traversing it.
  
  Revision  Changes    Path
  1.132     +47 -3     apr/memory/unix/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- apr_pools.c	13 Jan 2002 18:46:24 -0000	1.131
  +++ apr_pools.c	14 Jan 2002 09:18:40 -0000	1.132
  @@ -888,31 +888,75 @@
    * destroyed, in which case we abort().
    */
   
  +#if APR_HAS_THREADS
  +static int pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent,
  +                            apr_thread_mutex_t *mutex)
  +{
  +    apr_pool_t *child;
  +
  +    if (parent == NULL)
  +        return 0;
  +
  +#if APR_HAS_THREADS
  +    if (parent->mutex && parent->mutex != mutex)
  +        apr_thread_mutex_lock(parent->mutex);
  +#endif
  +
  +    child = parent->child;
  +
  +    while (child) {
  +        if (pool == child || pool_is_child_of(pool, child, parent->mutex)) {
  +#if APR_HAS_THREADS
  +            if (parent->mutex && parent->mutex != mutex)
  +                apr_thread_mutex_unlock(parent->mutex);
  +#endif
  +
  +            return 1;
  +        }
  + 
  +        child = child->sibling;
  +    }
  +
  +#if APR_HAS_THREADS
  +    if (parent->mutex && parent->mutex != mutex)
  +        apr_thread_mutex_unlock(parent->mutex);
  +#endif
  +
  +    return 0;
  +}
  +
  +#else
   static int pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent)
   {
       apr_pool_t *child;
  -   
  +
       if (parent == NULL)
           return 0;
   
       child = parent->child;
   
       while (child) {
  -        if (pool == child || pool_is_child_of(pool, child))
  +        if (pool == child || pool_is_child_of(pool, child)) {
               return 1;
  -        
  +        }
  + 
           child = child->sibling;
       }
   
       return 0;
   }
  +#endif
   
   static void check_integrity(apr_pool_t *pool)
   {
       if (pool == global_pool || global_pool == NULL)
           return;
   
  +#if APR_HAS_THREADS    
  +    if (!pool_is_child_of(pool, global_pool, NULL))
  +#else
       if (!pool_is_child_of(pool, global_pool))
  +#endif
       {
   #if defined(APR_POOL_DEBUG_VERBOSE)
           if (file_stderr) {
  
  
  

Mime
View raw message