apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/memory/unix apr_sms.c
Date Wed, 13 Jun 2001 01:35:48 GMT
dreid       01/06/12 18:35:48

  Modified:    memory/unix apr_sms.c
  Log:
  More cleanup...
  - fix a spelling mistake (whoops)
  - add a comment about why we call pre_destroy where we do for
    resets
  - make the child_cleanup calls more obvious by passing in the child
    rather than the whole sms structure
  
  Revision  Changes    Path
  1.22      +17 -13    apr/memory/unix/apr_sms.c
  
  Index: apr_sms.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- apr_sms.c	2001/06/13 00:31:14	1.21
  +++ apr_sms.c	2001/06/13 01:35:47	1.22
  @@ -120,7 +120,7 @@
       if (sms->realloc_fn)
           return sms->realloc_fn(sms, mem, size);
   
  -    /* XXX - shoulod we free the block passed in ??? */
  +    /* XXX - should we free the block passed in ??? */
       return NULL;
   }
   
  @@ -310,17 +310,21 @@
    */
   static void apr_sms_do_child_cleanups(apr_sms_t *sms)
   {
  -    if (!sms)
  -        return;
  -
  -    sms = sms->child;
       while (sms) {
  -        apr_sms_do_child_cleanups(sms);
  +        apr_sms_do_child_cleanups(sms->child);
           apr_sms_do_cleanups(sms->cleanups);
  -
  +        /*
  +         * We assume that all of our children & their siblings are created
  +         * from memory we've allocated, and as we're about to nuke it all 
  +         * we need to run the pre_destroy so things like locks can be 
  +         * cleaned up so we don't leak.
  +         * However, we aren't going to call destroy on a reset as we're about
  +         * to nuke them when we do the reset.  This is why all "leakable"
  +         * items created in an sms module MUST be cleaned up in the
  +         * pre_destroy not the destroy.
  +         */
           if (sms->pre_destroy_fn != NULL)
               sms->pre_destroy_fn(sms);
  -
           sms = sms->sibling;
       }
   }
  @@ -338,7 +342,7 @@
        * Run the cleanups of all child memory systems _including_
        * the accounting memory system.
        */
  -    apr_sms_do_child_cleanups(sms);
  +    apr_sms_do_child_cleanups(sms->child);
   
       /* Run all cleanups, the memory will be freed by the reset */
       apr_sms_do_cleanups(sms->cleanups);
  @@ -377,9 +381,10 @@
           /* 
            * Run the cleanups of all child memory systems _including_
            * the accounting memory system.
  +         * This also does the pre_destroy functions in the children.
            */
  -        apr_sms_do_child_cleanups(sms);
  -
  +        apr_sms_do_child_cleanups(sms->child);
  +        
           /* Run all cleanups, the memory will be freed by the destroy */
           apr_sms_do_cleanups(sms->cleanups);
       }
  @@ -392,8 +397,7 @@
                * child list (we will explicitly destroy it later in this block).
                */
               if (child->sibling != NULL)
  -                child->sibling->ref =
  -                    child->ref;
  +                child->sibling->ref = child->ref;
   
               *child->ref = child->sibling;
   
  
  
  

Mime
View raw message