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 13:45:19 GMT
striker     02/01/14 05:45:19

  Modified:    .        STATUS
               memory/unix apr_pools.c
  Log:
  In debug, no matter what the creation flags say, always
  create a lock.  Without it integrity_check and
  apr_pool_num_bytes blow up (because they traverse pools
  child lists that possibly belong to another thread, in
  combination with the pool having no lock).  However,
  this might actually hide problems like creating a
  child pool of a pool belonging to another thread.
  
  Revision  Changes    Path
  1.93      +26 -8     apr/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/apr/STATUS,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- STATUS	14 Jan 2002 10:05:15 -0000	1.92
  +++ STATUS	14 Jan 2002 13:45:19 -0000	1.93
  @@ -1,5 +1,5 @@
   APACHE PORTABLE RUNTIME (APR) LIBRARY STATUS:			-*-text-*-
  -Last modified at [$Date: 2002/01/14 10:05:15 $]
  +Last modified at [$Date: 2002/01/14 13:45:19 $]
   
   Release:
   
  @@ -46,13 +46,31 @@
   
   RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
   
  -    * Implement apr_pool_join and apr_pool_lock.  Those functions
  -      are noops at the moment.
  -
  -    * Add stats to the pools code.  We already have basic stats
  -      in debug mode.  Stats that tell us about wasted memory
  -      in the production code require more thought.
  -        Status: Sander Striker is looking into this (low priority)
  +    * Pools debugging
  +        - Find a way to do check if a pool is used in multiple
  +          threads, while the creation flags say it isn't.  IOW,
  +          when the pool was created with APR_POOL_FNEWALLOCATOR,
  +          but without APR_POOL_FLOCK.
  +          Currently, no matter what the creation flags say, we always
  +          create a lock.  Without it integrity_check() and
  +          apr_pool_num_bytes() blow up (because they traverse pools
  +          child lists that possibly belong to another thread, in
  +          combination with the pool having no lock).  However,
  +          this might actually hide problems like creating a child pool
  +          of a pool belonging to another thread.
  +          Maybe a debug function apr_pool_set_owner(apr_thread_t *) in
  +          combination with extra checks in integrity_check() will point
  +          out these problems.  apr_pool_set_owner() would need to be called
  +          everytime the owner(the thread the pool is being used in) of
  +          the pool changes.
  +
  +        - Implement apr_pool_join and apr_pool_lock.  Those functions
  +          are noops at the moment.
  +
  +        - Add stats to the pools code.  We already have basic stats
  +          in debug mode.  Stats that tell us about wasted memory
  +          in the production code require more thought.
  +            Status: Sander Striker is looking into this (low priority)
   
       * Deal with largefiles properly on those platforms that support it.
   
  
  
  
  1.137     +22 -10    apr/memory/unix/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
  retrieving revision 1.136
  retrieving revision 1.137
  diff -u -r1.136 -r1.137
  --- apr_pools.c	14 Jan 2002 12:16:59 -0000	1.136
  +++ apr_pools.c	14 Jan 2002 13:45:19 -0000	1.137
  @@ -162,6 +162,7 @@
   #else /* !defined(APR_POOL_DEBUG) */
       debug_node_t         *nodes;
       const char           *file_line;
  +    apr_uint32_t          creation_flags;
       unsigned int          stat_alloc;
       unsigned int          stat_total_alloc;
       unsigned int          stat_clear;
  @@ -1068,7 +1069,8 @@
   #if defined(APR_POOL_DEBUG_VERBOSE)
       if (file_stderr) {
           apr_file_printf(file_stderr,
  -            "POOL DEBUG: CLEAR  [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] (%u/%u/%u)\n",
  +            "POOL DEBUG: CLEAR  [%10lu/%10lu/%10lu] "
  +            "0x%08X \"%s\" [%s] (%u/%u/%u)\n",
               (unsigned long)apr_pool_num_bytes(pool, 0),
               (unsigned long)apr_pool_num_bytes(pool, 1),
               (unsigned long)apr_pool_num_bytes(global_pool, 1),
  @@ -1089,7 +1091,8 @@
   #if defined(APR_POOL_DEBUG_VERBOSE)
       if (file_stderr) {
           apr_file_printf(file_stderr,
  -            "POOL DEBUG: DESTROY [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] (%u/%u/%u)\n",
  +            "POOL DEBUG: DESTROY [%10lu/%10lu/%10lu] "
  +            "0x%08X \"%s\" [%s] (%u/%u/%u)\n",
               (unsigned long)apr_pool_num_bytes(pool, 0),
               (unsigned long)apr_pool_num_bytes(pool, 1),
               (unsigned long)apr_pool_num_bytes(global_pool, 1),
  @@ -1153,17 +1156,24 @@
       pool->abort_fn = abort_fn;
       pool->tag = file_line;
       pool->file_line = file_line;
  +    pool->creation_flags = flags;
   
       if ((flags & APR_POOL_FNEW_ALLOCATOR) == APR_POOL_FNEW_ALLOCATOR) {
   #if APR_HAS_THREADS
  -        if ((flags & APR_POOL_FLOCK) == APR_POOL_FLOCK) {
  -            apr_status_t rv;
  +        apr_status_t rv;
   
  -            if ((rv = apr_thread_mutex_create(&pool->mutex, 
  -                    APR_THREAD_MUTEX_DEFAULT, pool)) != APR_SUCCESS) {
  -                free(pool);
  -                return rv;
  -            }
  +        /* No matter what the creation flags say, always create
  +         * a lock.  Without it integrity_check and apr_pool_num_bytes
  +         * blow up (because they traverse pools child lists that
  +         * possibly belong to another thread, in combination with
  +         * the pool having no lock).  However, this might actually
  +         * hide problems like creating a child pool of a pool
  +         * belonging to another thread.
  +         */
  +        if ((rv = apr_thread_mutex_create(&pool->mutex, 
  +                APR_THREAD_MUTEX_DEFAULT, pool)) != APR_SUCCESS) {
  +            free(pool);
  +            return rv;
           }
   #endif
       }
  @@ -1200,12 +1210,14 @@
   #if defined(APR_POOL_DEBUG_VERBOSE)
       if (file_stderr) {
           apr_file_printf(file_stderr,
  -            "POOL DEBUG: CREATE  [%10lu/%10lu/%10lu] 0x%08X \"%s\" [%s] parent: 0x%08X
\"%s\"\n",
  +            "POOL DEBUG: CREATE  [%10lu/%10lu/%10lu] "
  +            "0x%08X \"%s\" [%s] flags=0x%X, parent=0x%08X \"%s\"\n",
               (unsigned long)0,
               (unsigned long)0,
               (unsigned long)apr_pool_num_bytes(global_pool, 1),
               (unsigned int)pool, pool->tag, 
               file_line,
  +            flags,
               (unsigned int)parent, parent ? parent->tag : "<null>");
       }
   #endif
  
  
  

Mime
View raw message