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_tracking.c
Date Sun, 10 Jun 2001 21:21:49 GMT
dreid       01/06/10 14:21:49

  Modified:    memory/unix apr_sms_tracking.c
  Log:
  Make locking conditional on having a lock to use and make the destroy
  function much cleaner.
  
  Submitted by:    Sander Striker <striker@samba-tng.org>
  Reviewed by:     David Reid <dreid@apache.org>
  
  Revision  Changes    Path
  1.10      +38 -39    apr/memory/unix/apr_sms_tracking.c
  
  Index: apr_sms_tracking.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms_tracking.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apr_sms_tracking.c	2001/06/10 14:45:32	1.9
  +++ apr_sms_tracking.c	2001/06/10 21:21:49	1.10
  @@ -100,7 +100,8 @@
           return NULL;
   
       tms = (apr_sms_tracking_t *)sms;
  -    apr_lock_acquire(tms->lock);
  +    if (tms->lock)
  +        apr_lock_acquire(tms->lock);
   
       node->next = tms->nodes;
       tms->nodes = node;
  @@ -108,7 +109,8 @@
       if (node->next)
           node->next->ref = &node->next;
   
  -    apr_lock_release(tms->lock);
  +    if (tms->lock)
  +        apr_lock_release(tms->lock);
   
       node++;
   
  @@ -127,7 +129,8 @@
           return NULL;
   
       tms = (apr_sms_tracking_t *)sms;
  -    apr_lock_acquire(tms->lock);
  +    if (tms->lock)
  +        apr_lock_acquire(tms->lock);
   
       node->next = tms->nodes;
       tms->nodes = node;
  @@ -135,7 +138,8 @@
       if (node->next)
           node->next->ref = &node->next;
   
  -    apr_lock_release(tms->lock);
  +    if (tms->lock)
  +        apr_lock_release(tms->lock);
   
       node++;
   
  @@ -149,19 +153,20 @@
       apr_track_node_t *node;
   
       tms = (apr_sms_tracking_t *)sms;
  -
  -
       node = (apr_track_node_t *)mem;
   
       if (node) {
           node--;
  -        apr_lock_acquire(tms->lock);
  +
  +        if (tms->lock)
  +            apr_lock_acquire(tms->lock);
           
           *(node->ref) = node->next;
           if (node->next)
               node->next->ref = node->ref;
  -        
  -        apr_lock_release(tms->lock);
  +
  +        if (tms->lock)
  +            apr_lock_release(tms->lock);
       }
   
       node = apr_sms_realloc(sms->parent,
  @@ -169,7 +174,8 @@
       if (!node)
           return NULL;
   
  -    apr_lock_acquire(tms->lock);
  +    if (tms->lock)
  +        apr_lock_acquire(tms->lock);
       
       node->next = tms->nodes;
       tms->nodes = node;
  @@ -177,7 +183,8 @@
       if (node->next)
           node->next->ref = &node->next;
   
  -    apr_lock_release(tms->lock);
  +    if (tms->lock)
  +        apr_lock_release(tms->lock);
       
       node++;
   
  @@ -195,13 +202,15 @@
   
       tms = (apr_sms_tracking_t *)sms;
    
  -    apr_lock_acquire(tms->lock);
  +    if (tms->lock)
  +        apr_lock_acquire(tms->lock);
   
       *(node->ref) = node->next;
       if (node->next)
           node->next->ref = node->ref;
    
  -    apr_lock_release(tms->lock);
  +    if (tms->lock)
  +        apr_lock_release(tms->lock);
            
       return apr_sms_free(sms->parent, node);
   }
  @@ -214,7 +223,8 @@
    
       tms = (apr_sms_tracking_t *)sms;
   
  -    apr_lock_acquire(tms->lock);
  +    if (tms->lock)
  +        apr_lock_acquire(tms->lock);
       
       while (tms->nodes) {
           node = tms->nodes;
  @@ -223,12 +233,15 @@
               node->next->ref = node->ref;
           if ((rv = apr_sms_free(sms->parent, 
                                  node)) != APR_SUCCESS) {
  -            apr_lock_release(tms->lock);
  +            if (tms->lock) {
  +                apr_lock_release(tms->lock);
  +            }
               return rv;
           }
       }
       
  -    apr_lock_release(tms->lock);
  +    if (tms->lock)
  +        apr_lock_release(tms->lock);
   
       return APR_SUCCESS;
   }
  @@ -244,9 +257,12 @@
       apr_sms_tracking_t *tms;
    
       tms = (apr_sms_tracking_t *)sms;
  -    apr_lock_acquire(tms->lock);
  -    apr_lock_destroy(tms->lock);
  -    tms->lock = NULL;
  +
  +    if (tms->lock) {
  +        apr_lock_acquire(tms->lock);
  +        apr_lock_destroy(tms->lock);
  +        tms->lock = NULL;
  +    }
       
       return APR_SUCCESS;    
   }
  @@ -254,26 +270,9 @@
   static apr_status_t apr_sms_tracking_destroy(apr_sms_t *sms)
   {
       apr_status_t rv;
  -    apr_sms_tracking_t *tms;
  -    apr_track_node_t *node;
  -    
  -    tms = (apr_sms_tracking_t *)sms;
  - 
  -    /* XXX - As we've already had the lock we've been using destroyed
  -     * in the pre_destroy function we can't use it.  However, if we
  -     * have threads trying to use the sms while another is trying to
  -     * destroy it, then we have serious problems anyway.
  -     */
  -    while (tms->nodes) {
  -        node = tms->nodes;
  -        *(node->ref) = node->next;
  -        if (node->next)
  -            node->next->ref = node->ref;
  -        if ((rv = apr_sms_free(sms->parent, node)) != APR_SUCCESS)
  -            return rv;
  -    }
  -    
  -    return apr_sms_free(sms->parent, sms);
  +
  +    if ((rv = apr_sms_reset(sms)) != APR_SUCCESS)
  +        return rv;
   }
   
   
  
  
  

Mime
View raw message