apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sander Striker" <stri...@apache.org>
Subject RE: cvs commit: apr/memory/unix apr_pools.c
Date Thu, 24 Jan 2002 12:57:09 GMT
> From: striker@apache.org [mailto:striker@apache.org]
> Sent: 24 January 2002 13:18
> To: apr-cvs@apache.org
> Subject: cvs commit: apr/memory/unix apr_pools.c
> 
> striker     02/01/24 04:18:18
> 
>   Modified:    .        configure.in
>                memory/unix apr_pools.c
>   Log:
>   Introduce a new configure option: --enable-pool-debug
>   This allows us to select the pools debug mode at configure
>   time without messing about in source files.
>   
>   At the same time we switch to a flag system, so different
>   debug features can be switched on or off. e.g.:
>    --enable-pool-debug="verbose lifetime"
>   
>   Revision  Changes    Path
>   1.400     +41 -0     apr/configure.in

Introduction to the debug modes:

./configure --enable-pool-debug           ; default debug mode (malloc system)
./configure --enable-pool-debug=yes       ; same

./configure --enable-pool-debug=verbose   ; verbose output
./configure --enable-pool-debug=lifetime  ; lifetime checking
./configure --enable-pool-debug=owner     ; owner checking

./configure --enable-pool-debug=all       ; enable all debug modes

The general debug mode (which is always enabled when any debug
mode is selected) gives you a malloc using system for each allocation.
This is extremely usefull in combination with electric fence
(--with-efence) or other third party tools like purify.

The verbose mode gives you output on stderr (which in httpd is
redirected to the error_log).  It gives you information on
events, like pool creation (CREATE), pool clear (CLEAR), etc.
It also gives you stats, pid/tid, tag.  This can easily be
modified by changing apr_pool_log_event in apr_pools.c.

The lifetime option checks if the pool is still a relative
of the global pool on every pool operation.  If not, the pool
was previously destroyed and we abort.

The owner option checks if the pool being used is owned by
the current thread performing the operation.  If not, we
abort.  The ownership of the pool can be transferred using
apr_pool_set_owner*.


Sander

*) apr_pool_set_owner was not part of this commit.  
It gave me some trouble to where to put it.  I had a function
like this:

APR_DECLARE(void) apr_pool_set_owner(apr_pool_t *pool,
                                     apr_os_thread_t tid);

This declaration can only be placed in apr_portable.h (due to
circular dependencies), which is a lousy location for a debug
function.

The other approach is to use apr_thread_t *, but I couldn't
find the way to do:

apr_thread_equal(thread1, thread2); /* where thread1 and 2
                                     * are apr_thread_t *
                                     */

Or apr_thread_current() which gives me, or fills an
apr_thread_t * with the current thread info.

So, either I'm looking with my eyes shut, or the thread API
is lacking some functionality.

 

Mime
View raw message