apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/misc/unix errorcodes.c
Date Sat, 19 May 2001 13:53:06 GMT
dreid       01/05/19 06:53:06

  Modified:    memory/unix apr_sms.c
               include  apr_errno.h apr_sms.h
               misc/unix errorcodes.c
  Log:
   More cleanup and improvement of the memory code...
  
  - general code clean up (from Sander Striker)
  - add a type flag to the cleanup's we register (from Sander Striker)
  - add an extra error code to signify you asked for a function
    that isn't available in a memory system
  - add the new memory codes into errorcodes.c so we can report
    the errors (missed first time around)
  
  The types for the cleanups should allow us to be much more selective
  in the cleanup we call.  Sander has some work in progress that will use
  these to provide a better feel of how they'll work.
  
  Submitted by:	Sander Striker <striker@samba-tng.org>
  Reviewed by:	David Reid
  
  Revision  Changes    Path
  1.3       +165 -98   apr/memory/unix/apr_sms.c
  
  Index: apr_sms.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_sms.c	2001/05/14 23:19:44	1.2
  +++ apr_sms.c	2001/05/19 13:53:06	1.3
  @@ -76,6 +76,7 @@
   struct apr_sms_cleanup
   {
       struct apr_sms_cleanup *next;
  +    apr_int32_t type;
       void *data;
       apr_status_t (*cleanup_fn)(void *);
   };
  @@ -107,13 +108,12 @@
   #ifdef APR_ASSERT_MEMORY
       assert(mem_sys);
       assert(mem_sys->malloc_fn);
  -    assert(mem_sys->calloc_fn);
   #endif
   
       if (size == 0)
           return NULL;
   
  -    if (mem_sys->calloc_fn == NULL){
  +    if (!mem_sys->calloc_fn){
           /* Assumption - if we don't have calloc we have
            * malloc, might be bogus...
            */
  @@ -132,7 +132,7 @@
       assert(mem_sys->realloc_fn);
   #endif
      
  -    if (mem == NULL)
  +    if (!mem)
           return apr_sms_malloc(mem_sys, size);
   
       if (size == 0)
  @@ -147,20 +147,20 @@
   APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *mem_sys,
                                          void *mem)
   {
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +       
   #ifdef APR_ASSERT_MEMORY
       assert(mem_sys->free_fn);
   #endif
   
  -    if (!mem_sys)
  -        return APR_EMEMSYS;
  -  
  -    if (mem == NULL)
  +    if (!mem)
           return APR_EINVAL;
   
  -    if (mem_sys->free_fn != NULL)
  +    if (!mem_sys->free_fn)
           return mem_sys->free_fn(mem_sys, mem);  
   
  -    return APR_SUCCESS;
  +    return APR_EMEMFUNC;
   }
   
   /*
  @@ -181,7 +181,7 @@
   {
       apr_sms_t *mem_sys;
   
  -    if (memory == NULL)
  +    if (!memory)
           return NULL;
   
       /* Just typecast it, and clear it */
  @@ -192,16 +192,11 @@
       mem_sys->parent_mem_sys = parent_mem_sys;
       mem_sys->accounting_mem_sys = mem_sys;
   
  -    if (parent_mem_sys != NULL)
  -    {
  -        if ((mem_sys->sibling_mem_sys = 
  -           parent_mem_sys->child_mem_sys) != NULL)
  -        {
  -            mem_sys->sibling_mem_sys->ref_mem_sys = 
  -              &mem_sys->sibling_mem_sys;
  +    if (parent_mem_sys != NULL){
  +        if (mem_sys->sibling_mem_sys = parent_mem_sys->child_mem_sys){
  +            mem_sys->sibling_mem_sys->ref_mem_sys = &mem_sys->sibling_mem_sys;
           }
  -        mem_sys->ref_mem_sys = 
  -          &parent_mem_sys->child_mem_sys;
  +        mem_sys->ref_mem_sys = &parent_mem_sys->child_mem_sys;
           parent_mem_sys->child_mem_sys = mem_sys;
       }
       /* This seems a bit redundant, but we're not taking chances */
  @@ -231,15 +226,11 @@
        * or destroy function. And to avoid half implementations
        * we require reset to be present when destroy is.
        */
  -    assert(mem_sys->free_fn != NULL ||
  -         (mem_sys->destroy_fn != NULL &&
  -          mem_sys->reset_fn != NULL));
  +    assert(mem_sys->free_fn || (mem_sys->destroy_fn && mem_sys->reset_fn));
   
  -    assert(mem_sys->destroy_fn == NULL ||
  -         mem_sys->reset_fn != NULL);
  +    assert(!mem_sys->destroy_fn || mem_sys->reset_fn);
     
  -    assert(mem_sys->reset_fn == NULL ||
  -         mem_sys->destroy_fn != NULL);
  +    assert(!mem_sys->reset_fn || mem_sys->destroy_fn);
   
       /*
        * Make sure all accounting memory dies with the memory system.
  @@ -247,8 +238,7 @@
        * is either the memory system itself or a direct child.
        */
       assert(mem_sys->accounting_mem_sys == mem_sys ||
  -	 mem_sys->accounting_mem_sys->parent_mem_sys == 
  -	   mem_sys);
  +	 mem_sys->accounting_mem_sys->parent_mem_sys ==  mem_sys);
   
       /*
        * A non-tracking memory system can be the child of
  @@ -260,8 +250,7 @@
           return;
   
       parent = mem_sys
  -    while (parent)
  -    {
  +    while (parent){
           if (apr_sms_is_tracking(parent))
               return; /* Tracking memory system found, return satisfied ;-) */
   
  @@ -304,12 +293,11 @@
    */
   static void apr_sms_do_child_cleanups(apr_sms_t *mem_sys)
   {
  -    if (mem_sys == NULL)
  +    if (!mem_sys)
           return;
   
       mem_sys = mem_sys->child_mem_sys;
  -    while (mem_sys)
  -    {
  +    while (mem_sys){
           apr_sms_do_child_cleanups(mem_sys);
           apr_sms_do_cleanups(mem_sys);
   
  @@ -324,8 +312,9 @@
   {
       if (!mem_sys)
           return APR_EMEMSYS;
  +
       if (!mem_sys->reset_fn)
  -        return APR_EINVAL; /* Not sure if this is right... */
  +        return APR_EMEMFUNC;
   
       /* 
        * Run the cleanups of all child memory systems _including_
  @@ -362,8 +351,7 @@
       if (!mem_sys)
           return APR_EMEMSYS;
   
  -    if (apr_sms_is_tracking(mem_sys))
  -    {
  +    if (apr_sms_is_tracking(mem_sys)){
           /* 
            * Run the cleanups of all child memory systems _including_
            * the accounting memory system.
  @@ -384,11 +372,9 @@
                * child list (we will explicitly destroy it later in this block).
                */
               if (child_mem_sys->sibling_mem_sys != NULL)
  -	            child_mem_sys->sibling_mem_sys->ref_mem_sys =
  -	              child_mem_sys->ref_mem_sys;
  +	            child_mem_sys->sibling_mem_sys->ref_mem_sys = child_mem_sys->ref_mem_sys;
   
  -            *child_mem_sys->ref_mem_sys = 
  -            child_mem_sys->sibling_mem_sys;
  +            *child_mem_sys->ref_mem_sys = child_mem_sys->sibling_mem_sys;
   
               /* Set this fields so destroy will work */
               child_mem_sys->ref_mem_sys = NULL;
  @@ -397,8 +383,7 @@
   
           /* Visit all children and destroy them */
           child_mem_sys = mem_sys->child_mem_sys;
  -        while (child_mem_sys != NULL)
  -        {
  +        while (child_mem_sys != NULL){
               sibling_mem_sys = child_mem_sys->sibling_mem_sys;
               apr_sms_destroy(child_mem_sys);
               child_mem_sys = sibling_mem_sys;
  @@ -408,8 +393,7 @@
            * If the accounting memory system _is_ tracking, we also know that it is
            * not the memory system itself.
            */
  -        if (apr_sms_is_tracking(mem_sys->accounting_mem_sys))
  -        {
  +        if (apr_sms_is_tracking(mem_sys->accounting_mem_sys)){
               /* 
                * Run all cleanups, the memory will be freed by the destroying of the
                * accounting memory system.
  @@ -429,12 +413,10 @@
           {
               /* Run all cleanups, free'ing memory as we go */
               cleanup = mem_sys->cleanups;
  -            while (cleanup)
  -            {
  +            while (cleanup){
                   cleanup->cleanup_fn(cleanup->data);
                   next_cleanup = cleanup->next;
  -                apr_sms_free(mem_sys->accounting_mem_sys, 
  -			       cleanup);
  +                apr_sms_free(mem_sys->accounting_mem_sys, cleanup);
                   cleanup = next_cleanup;
               }
   
  @@ -452,33 +434,32 @@
     }
   
     /* Remove the memory system from the parent memory systems child list */
  -  if (mem_sys->sibling_mem_sys != NULL)
  -      mem_sys->sibling_mem_sys->ref_mem_sys =
  -        mem_sys->ref_mem_sys;
  -  if (mem_sys->ref_mem_sys != NULL)
  +  if (mem_sys->sibling_mem_sys)
  +      mem_sys->sibling_mem_sys->ref_mem_sys = mem_sys->ref_mem_sys;
  +
  +  if (mem_sys->ref_mem_sys)
         *mem_sys->ref_mem_sys = mem_sys->sibling_mem_sys;
   
     /* Call the pre-destroy if present */
  -  if (mem_sys->pre_destroy_fn != NULL)
  +  if (mem_sys->pre_destroy_fn)
         mem_sys->pre_destroy_fn(mem_sys);
   
     /* 1 - If we have a self destruct, use it */
  -  if (mem_sys->destroy_fn != NULL)
  +  if (mem_sys->destroy_fn)
         return mem_sys->destroy_fn(mem_sys);
   
     /* 2 - If we don't have a parent, free using ourselves */
  -  else if (mem_sys->parent_mem_sys == NULL)
  +  else if (!mem_sys->parent_mem_sys)
         return mem_sys->free_fn(mem_sys, mem_sys);
   
     /* 3 - If we do have a parent and it has a free function, use it */
  -  else if (mem_sys->parent_mem_sys->free_fn != NULL)
  +  else if (mem_sys->parent_mem_sys->free_fn)
         return apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
   
     /* 4 - Assume we are the child of a tracking memory system, and do nothing */
   #ifdef APR_ASSERT_MEMORY
       mem_sys = mem_sys->parent_mem_sys;
  -    while (mem_sys)
  -    {
  +    while (mem_sys){
           if (apr_sms_is_tracking(mem_sys))
               return APR_SUCCESS;
   
  @@ -492,12 +473,13 @@
   APR_DECLARE(apr_status_t) apr_sms_is_ancestor(apr_sms_t *a,
                                                 apr_sms_t *b)
   {
  +    if (!b)
  +        return APR_EMEMSYS;
  +
   #ifdef APR_ASSERT_MEMORY
       assert(a != NULL);
       assert(b != NULL);
   #endif
  -    if (!b)
  -        return APR_EINVAL;
           
       while (b && b != a)
           b = b->parent_mem_sys;
  @@ -506,58 +488,58 @@
       return !(b == a); 
   }
   
  -APR_DECLARE(void) apr_sms_threadsafe_lock(apr_sms_t *mem_sys)
  +APR_DECLARE(apr_status_t) apr_sms_threadsafe_lock(apr_sms_t *mem_sys)
   {
  -#ifdef APR_ASSERT_MEMORY
  -    assert(mem_sys != NULL);
  -#endif
  -
       if (!mem_sys)
  -        return;       
  -    if (mem_sys->threadsafe_lock_fn != NULL)
  -        mem_sys->threadsafe_lock_fn(mem_sys);
  +        return APR_EMEMSYS;       
  +
  +    if (!mem_sys->lock_fn)
  +        return APR_EMEMFUNC;
  +
  +    if (mem_sys->lock_fn)
  +        return mem_sys->lock_fn(mem_sys);
   }
   
  -APR_DECLARE(void) apr_sms_threadsafe_unlock(apr_sms_t *mem_sys)
  +APR_DECLARE(apr_status_t) apr_sms_threadsafe_unlock(apr_sms_t *mem_sys)
   {
  -#ifdef APR_ASSERT_MEMORY
  -    assert(mem_sys != NULL);
  -#endif
  -
       if (!mem_sys)
  -        return;
  -    if (mem_sys->threadsafe_unlock_fn != NULL)
  -        mem_sys->threadsafe_unlock_fn(mem_sys);
  +        return APR_EMEMSYS;
  +
  +    if (!mem_sys->unlock_fn)
  +        return APR_EMEMFUNC;
  +        
  +    if (mem_sys->unlock_fn)
  +        return mem_sys->unlock_fn(mem_sys);
   }
   
   /*
    * memory system cleanup management functions
    */
   
  -APR_DECLARE(apr_status_t) 
  -apr_sms_cleanup_register(apr_sms_t *mem_sys, void *data,
  -                         apr_status_t (*cleanup_fn)(void *))
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *mem_sys, 
  +                                                   apr_int32_t type, void *data,
  +                                                   apr_status_t (*cleanup_fn)(void *))
   {
       struct apr_sms_cleanup *cleanup;
   
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +
   #ifdef APR_ASSERT_MEMORY
       assert(mem_sys->accounting_mem_sys != NULL);
   #endif
  -
  -    if (!mem_sys)
  -        return APR_EMEMSYS;
       
  -    if (cleanup_fn == NULL)
  -        return APR_EINVAL;
  +    if (!cleanup_fn)
  +        return APR_EMEMFUNC;
   
       cleanup = (struct apr_sms_cleanup *)
  -	    apr_sms_malloc(mem_sys->accounting_mem_sys,
  -                       sizeof(struct apr_sms_cleanup));
  +	    apr_sms_malloc(mem_sys->accounting_mem_sys, sizeof(struct apr_sms_cleanup));
   
  -    if (cleanup == NULL)
  +    if (!cleanup)
           return APR_ENOMEM;
   
       cleanup->data = data;
  +    cleanup->type = type;
       cleanup->cleanup_fn = cleanup_fn;
       cleanup->next = mem_sys->cleanups;
       mem_sys->cleanups = cleanup;
  @@ -566,25 +548,25 @@
   }
   
   APR_DECLARE(apr_status_t)
  -apr_sms_cleanup_unregister(apr_sms_t *mem_sys, void *data,
  +apr_sms_cleanup_unregister(apr_sms_t *mem_sys, apr_int32_t type, void *data,
                              apr_status_t (*cleanup_fn)(void *))
   {
       struct apr_sms_cleanup *cleanup;
       struct apr_sms_cleanup **cleanup_ref;
   
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +
   #ifdef APR_ASSERT_MEMORY
       assert(mem_sys->accounting_mem_sys != NULL);
   #endif
  -
  -    if (!mem_sys)
  -        return APR_EMEMSYS;
           
       cleanup = mem_sys->cleanups;
       cleanup_ref = &mem_sys->cleanups;
       while (cleanup)
       {
  -        if (cleanup->data == data && cleanup->cleanup_fn == cleanup_fn)
  -        {
  +        if ((type == 0 || cleanup->cleanup_fn == cleanup_fn) &&
  +            cleanup->data == data && cleanup->cleanup_fn == cleanup_fn) {
               *cleanup_ref = cleanup->next;
   
               mem_sys = mem_sys->accounting_mem_sys;
  @@ -603,10 +585,95 @@
       return APR_ENOCLEANUP;
   }
   
  -APR_DECLARE(apr_status_t) 
  -apr_sms_cleanup_run(apr_sms_t *mem_sys, void *data, 
  -			        apr_status_t (*cleanup_fn)(void *))
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t *mem_sys, 
  +                                                          apr_int32_t type)
   {
  -    apr_sms_cleanup_unregister(mem_sys, data, cleanup_fn);
  -    return cleanup_fn(data);
  +    struct apr_sms_cleanup *cleanup;
  +    struct apr_sms_cleanup **cleanup_ref;
  +    apr_status_t rv = APR_ENOCLEANUP;
  +
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +        
  +#ifdef APR_ASSERT_MEMORY
  +    assert(mem_sys->accounting_mem_sys != NULL);
  +#endif
  +    
  +    cleanup = mem_sys->cleanups;
  +    cleanup_ref = &mem_sys->cleanups;
  +    mem_sys = mem_sys->accounting_mem_sys;
  +    while (cleanup) {
  +        if (type == 0 || cleanup->type == type) {
  +            *cleanup_ref = cleanup->next;
  +
  +            if (mem_sys->free_fn != NULL)
  +                apr_sms_free(mem_sys, cleanup);
  +
  +            cleanup = *cleanup_ref;
  +            rv = APR_SUCCESS;
  +        }
  +        else {
  +            cleanup_ref = &cleanup->next;
  +            cleanup = cleanup->next;
  +        }
  +    }
  +
  +    /* The cleanup function should have been registered previously */
  +    return rv;
   }
  +
  +APR_DECLARE(apr_status_t)  apr_sms_cleanup_run(apr_sms_t *mem_sys, apr_int32_t type,
  +                                               void *data, 
  +			                                   apr_status_t (*cleanup_fn)(void *))
  +{
  +    apr_status_t rv;
  +
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +
  +    if ((rv = apr_sms_cleanup_unregister(mem_sys, type, data, cleanup_fn)) != APR_SUCCESS)
  +        return rv;
  +
  +     return cleanup_fn(data);
  +}
  +
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *mem_sys, 
  +                                                   apr_int32_t type)
  +{
  +    struct apr_sms_cleanup *cleanup;
  +    struct apr_sms_cleanup **cleanup_ref;
  +    apr_status_t rv = APR_ENOCLEANUP;
  +
  +    if (!mem_sys)
  +        return APR_EMEMSYS;
  +        
  +#ifdef APR_ASSERT_MEMORY
  +    assert(mem_sys->accounting_mem_sys != NULL);
  +#endif
  +    
  +    cleanup = mem_sys->cleanups;
  +    cleanup_ref = &mem_sys->cleanups;
  +    mem_sys = mem_sys->accounting_mem_sys;
  +    while (cleanup)
  +    {
  +        if (type == 0 || cleanup->type == type) {
  +            *cleanup_ref = cleanup->next;
  +
  +            cleanup->cleanup_fn(cleanup->data);
  +            
  +            if (mem_sys->free_fn != NULL)
  +                apr_sms_free(mem_sys, cleanup);
  +
  +            cleanup = *cleanup_ref;
  +            rv = APR_SUCCESS;
  +        }
  +        else {
  +            cleanup_ref = &cleanup->next;
  +            cleanup = cleanup->next;
  +        }
  +    }
  +
  +    /* The cleanup function should have been registered previously */
  +    return rv;
  +}
  +
  
  
  
  1.63      +7 -4      apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_errno.h,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- apr_errno.h	2001/05/13 12:03:28	1.62
  +++ apr_errno.h	2001/05/19 13:53:06	1.63
  @@ -180,9 +180,11 @@
    * APR_EGENERAL     General failure (specific information not available)
    * APR_EBADIP       The specified IP address is invalid
    * APR_EBADMASK     The specified netmask is invalid
  - * APR_ENOCLEANUP     There is no memory cleanup available
  - * APR_EMEMSYS        An invalid memory system was passed in to an 
  - *                    apr_sms function
  + * APR_ENOCLEANUP   There is no memory cleanup available
  + * APR_EMEMSYS      An invalid memory system was passed in to an 
  + *                  apr_sms function
  + * APR_EMEMFUNC     A function was called that isn't available in the
  + *                  selected memory system
    * </PRE>
    *
    * <PRE>
  @@ -253,6 +255,7 @@
   #define APR_EBADPATH       (APR_OS_START_ERROR + 24)
   #define APR_ENOCLEANUP     (APR_OS_START_ERROR + 25)
   #define APR_EMEMSYS        (APR_OS_START_ERROR + 26)
  +#define APR_EMEMFUNC       (APR_OS_START_ERROR + 27)
   
   /* APR ERROR VALUE TESTS */
   #define APR_STATUS_IS_ENOSTAT(s)        ((s) == APR_ENOSTAT)
  @@ -281,7 +284,7 @@
   #define APR_STATUS_IS_EBADPATH(s)       ((s) == APR_EBADPATH)
   #define APR_STATUS_IS_ENOCLEANUP(s)     ((s) == APR_ENOCLEANUP)
   #define APR_STATUS_IS_EMEMSYS(s)        ((s) == APR_EMEMSYS)
  -
  +#define APR_STATUS_IS_EMEMFUNC(s)       ((s) == APR_EMEMFUNC)
   
   /* APR STATUS VALUES */
   #define APR_INCHILD        (APR_OS_START_STATUS + 1)
  
  
  
  1.2       +53 -19    apr/include/apr_sms.h
  
  Index: apr_sms.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_sms.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_sms.h	2001/05/14 22:56:12	1.1
  +++ apr_sms.h	2001/05/19 13:53:06	1.2
  @@ -70,6 +70,11 @@
   extern "C" {
   #endif
   
  +/* The various types of cleanup's we can offer */
  +#define APR_ALL_CLEANUPS      0x0000
  +#define APR_CHILD_CLEANUP     0x0001
  +#define APR_PARENT_CLEANUP    0x0002
  +
   /**
    * @package APR memory system
    */
  @@ -91,16 +96,16 @@
   
     struct apr_sms_cleanup *cleanups;
   
  -  void * (*malloc_fn)(apr_sms_t *mem_sys, apr_size_t size);
  -  void * (*calloc_fn)(apr_sms_t *mem_sys, apr_size_t size);
  -  void * (*realloc_fn)(apr_sms_t *mem_sys, void *memory, 
  -                       apr_size_t size);
  -  apr_status_t (*free_fn)(apr_sms_t *mem_sys, void *memory);
  -  apr_status_t (*reset_fn)(apr_sms_t *mem_sys);
  -  void (*pre_destroy_fn)(apr_sms_t *mem_sys);
  +  void * (*malloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  +  void * (*calloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  +  void * (*realloc_fn)      (apr_sms_t *mem_sys, void *memory, 
  +                             apr_size_t size);
  +  apr_status_t (*free_fn)   (apr_sms_t *mem_sys, void *memory);
  +  apr_status_t (*reset_fn)  (apr_sms_t *mem_sys);
  +  void (*pre_destroy_fn)    (apr_sms_t *mem_sys);
     apr_status_t (*destroy_fn)(apr_sms_t *mem_sys);
  -  void (*threadsafe_lock_fn)(apr_sms_t *mem_sys);
  -  void (*threadsafe_unlock_fn)(apr_sms_t *mem_sys);
  +  apr_status_t (*lock_fn)   (apr_sms_t *mem_sys);
  +  apr_status_t (*unlock_fn) (apr_sms_t *mem_sys);
   };
   
   /*
  @@ -209,17 +214,17 @@
   /**
    * Perform thread-safe locking required whilst this memory system is modified
    * @param mem_sys The memory system to be locked for thread-safety
  - * @deffunc void apr_sms_threadsafe_lock(apr_sms_t *mem_sys)
  + * @deffunc void apr_sms_lock(apr_sms_t *mem_sys)
    */
  -APR_DECLARE(void) apr_sms_threadsafe_lock(apr_sms_t *mem_sys);
  +APR_DECLARE(apr_status_t) apr_sms_lock(apr_sms_t *mem_sys);
   
   /**
    * Release thread-safe locking required whilst this memory system was
    * being modified
    * @param mem_sys The memory system to be released from thread-safety
  - * @deffunc void apr_sms_threadsafe_unlock(apr_sms_t *mem_sys)
  + * @deffunc void apr_sms_unlock(apr_sms_t *mem_sys)
    */
  -APR_DECLARE(void) apr_sms_threadsafe_unlock(apr_sms_t *mem_sys);
  +APR_DECLARE(apr_status_t) apr_sms__unlock(apr_sms_t *mem_sys);
   
   /**
    * Determine if memory system a is an ancestor of memory system b
  @@ -238,38 +243,67 @@
   /**
    * Register a function to be called when a memory system is reset or destroyed
    * @param mem_sys The memory system to register the cleanup function with
  + * @param type The type of cleanup to register
    * @param data The data to pass to the cleanup function
    * @param cleanup_fn The function to call when the memory system is reset or
    *        destroyed
  - * @deffunc void apr_sms_cleanup_register(apr_sms_t *mem_sys,
  + * @deffunc void apr_sms_cleanup_register(apr_sms_t *mem_sys, apr_int32_t type,
    *		   void *data, apr_status_t (*cleanup_fn)(void *));
    */
  -APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *mem_sys, void *data, 
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *mem_sys, apr_int32_t type,
  +                                                   void *data, 
                                                      apr_status_t (*cleanup_fn)(void *));
   
   /**
    * Unregister a previously registered cleanup function
    * @param mem_sys The memory system the cleanup function is registered
    *        with
  + * @param type The type of the cleanup to unregister
    * @param data The data associated with the cleanup function
    * @param cleanup_fn The registered cleanup function
    * @deffunc void apr_sms_cleanup_unregister(apr_sms_t *mem_sys,
    *		   void *data, apr_status_t (*cleanup_fn)(void *));
    */
  -APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *mem_sys, void *data,
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *mem_sys, apr_int32_t type,
  +                                                     void *data,
                                                        apr_status_t (*cleanup)(void *));
   
   /**
  + * Unregister all previously registered cleanup functions of the specified type
  + * @param mem_sys The memory system the cleanup functions are registered with
  + * @param type The type associated with the cleanup function. Pass 0 to 
  + *        unregister all cleanup functions.
  + * @deffunc apr_status_t apr_sms_cleanup_unregister_type(apr_sms_t *mem_sys,
  + *                 apr_int32_t type);
  + */
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t *mem_sys,
  +                                                           apr_int32_t type);
  +
  +/**
    * Run the specified cleanup function immediately and unregister it
    * @param mem_sys The memory system the cleanup function is registered
    *        with
  + * @param mem_sys The memory system the cleanup function is registered with
  + * @param type The type associated with the cleanup function. Pass 0 to ignore type.
    * @param data The data associated with the cleanup function
    * @param cleanup The registered cleanup function
  - * @deffunc apr_status_t apr_sms_cleanup_run(apr_sms_t *mem_sys,
  - *			   void *data, apr_status_t (*cleanup)(void *));
  + * @deffunc apr_status_t apr_sms_cleanup_run(apr_sms_t *mem_sys, 
  + *                 apr_int32_t type, void *data, apr_status_t (*cleanup)(void *));
    */
  -APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *mem_sys, void *data,
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *mem_sys, 
  +                                              apr_int32_t type, void *data,
                                                 apr_status_t (*cleanup)(void *));
  +
  +/**
  + * Run the specified type of cleanup functions immediately and unregister them
  + * @param mem_sys The memory system the cleanup functions are registered with
  + * @param type The category of cleanup functions to run. Pass 0 to run all
  + *        cleanup functions.
  + * @deffunc apr_status_t apr_sms_cleanup_run_type(apr_sms_t *mem_sys,
  + *	           apr_int32_t type);
  + */
  +APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *mem_sys, 
  +                                                   apr_int32_t type);
   
   /**
    * Create a standard malloc/realloc/free memory system
  
  
  
  1.37      +8 -1      apr/misc/unix/errorcodes.c
  
  Index: errorcodes.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/errorcodes.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- errorcodes.c	2001/05/16 03:49:16	1.36
  +++ errorcodes.c	2001/05/19 13:53:06	1.37
  @@ -166,7 +166,14 @@
           return "The given path was above the root path";
       case APR_EBADPATH:
           return "The given path misformatted or contained invalid characters";
  -     default:
  +    case APR_EMEMSYS:
  +        return "The memory system passed does not exist";
  +    case APR_EMEMFUNC:
  +        return "The function requested is not available in the memory "
  +               "system used";
  +    case APR_ENOCLEANUP:
  +        return "The requested cleanup function does not exist";
  +    default:
           return "Error string not specified yet";
       }
   }
  
  
  

Mime
View raw message