httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@hyperreal.org
Subject cvs commit: apache-2.0/src/lib/apr/lib apr_pools.c
Date Mon, 11 Oct 1999 15:28:03 GMT
stoddard    99/10/11 08:28:03

  Modified:    src/lib/apr/lib apr_pools.c
  Log:
  Migrate pool locking to use apr locks.
  
  Revision  Changes    Path
  1.15      +25 -18    apache-2.0/src/lib/apr/lib/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_pools.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- apr_pools.c	1999/10/11 14:20:41	1.14
  +++ apr_pools.c	1999/10/11 15:28:02	1.15
  @@ -71,6 +71,7 @@
   #include "apr_general.h"
   #include "apr_pools.h"
   #include "apr_lib.h"
  +#include "apr_lock.h"
   #include "misc.h"
   #ifdef HAVE_SYS_STAT_H
   #include <sys/stat.h>
  @@ -204,9 +205,10 @@
    * Static cells for managing our internal synchronisation.
    */
   static union block_hdr *block_freelist = NULL;
  -static ap_mutex_t *alloc_mutex = NULL;
  -static ap_mutex_t *spawn_mutex = NULL;
   
  +static ap_lock_t *alloc_mutex;
  +static ap_lock_t *spawn_mutex;
  +
   #ifdef POOL_DEBUG
   static char *known_stack_point;
   static int stack_direction;
  @@ -337,7 +339,7 @@
   	return;			/* Sanity check --- freeing empty pool? */
       }
   
  -    (void) ap_acquire_mutex(alloc_mutex);
  +    ap_lock(alloc_mutex);
       old_free_list = block_freelist;
       block_freelist = blok;
   
  @@ -385,7 +387,7 @@
       num_blocks_freed += num_blocks;
   #endif /* ALLOC_STATS */
   
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
   #endif /* ALLOC_USE_MALLOC */
   }
   
  @@ -475,7 +477,7 @@
   
       ap_block_alarms();
   
  -    (void) ap_acquire_mutex(alloc_mutex);
  +    ap_lock(alloc_mutex);
   
       blok = new_block(POOL_HDR_BYTES);
       new_pool = (ap_pool_t *) blok->h.first_avail;
  @@ -497,7 +499,7 @@
   	p->sub_pools = new_pool;
       }
   
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
       ap_unblock_alarms();
   
       return new_pool;
  @@ -540,8 +542,13 @@
       known_stack_point = &s;
       stack_var_init(&s);
   #endif
  -    alloc_mutex = ap_create_mutex(NULL);
  -    spawn_mutex = ap_create_mutex(NULL);
  +    ap_create_lock(NULL, APR_MUTEX, APR_INTRAPROCESS,
  +                   NULL,
  +                   &alloc_mutex);
  +    ap_create_lock(NULL, APR_MUTEX, APR_INTRAPROCESS,
  +                   NULL,
  +                   &spawn_mutex);
  +
       permanent_pool = ap_make_sub_pool(NULL);
   #ifdef ALLOC_STATS
       atexit(dump_stats);
  @@ -556,11 +563,11 @@
   {
       ap_block_alarms();
   
  -    (void) ap_acquire_mutex(alloc_mutex);
  +    ap_lock(alloc_mutex);
       while (a->sub_pools) {
   	ap_destroy_real_pool(a->sub_pools);
       }
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
       /*
        * Don't hold the mutex during cleanups.
        */
  @@ -600,8 +607,8 @@
   {
       ap_block_alarms();
       ap_clear_real_pool(a);
  +    ap_lock(alloc_mutex);
   
  -    (void) ap_acquire_mutex(alloc_mutex);
       if (a->parent) {
   	if (a->parent->sub_pools == a) {
   	    a->parent->sub_pools = a->sub_next;
  @@ -613,7 +620,7 @@
   	    a->sub_next->sub_prev = a->sub_prev;
   	}
       }
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
   
       free_blocks(a->first);
       ap_unblock_alarms();
  @@ -821,7 +828,7 @@
   
       ap_block_alarms();
   
  -    (void) ap_acquire_mutex(alloc_mutex);
  +    ap_lock(alloc_mutex);
   
       blok = new_block(size);
       a->last->h.next = blok;
  @@ -830,7 +837,7 @@
       blok->h.owning_pool = a;
   #endif
   
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
   
       ap_unblock_alarms();
   
  @@ -966,9 +973,9 @@
       cur_len = strp - blok->h.first_avail;
   
       /* must try another blok */
  -    (void) ap_acquire_mutex(alloc_mutex);
  +    ap_lock(alloc_mutex);
       nblok = new_block(2 * cur_len);
  -    (void) ap_release_mutex(alloc_mutex);
  +    ap_unlock(alloc_mutex);
       memcpy(nblok->h.first_avail, blok->h.first_avail, cur_len);
       ps->vbuff.curpos = nblok->h.first_avail + cur_len;
       /* save a byte for the NUL terminator */
  @@ -977,10 +984,10 @@
       /* did we allocate the current blok? if so free it up */
       if (ps->got_a_new_block) {
   	debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail);
  -	(void) ap_acquire_mutex(alloc_mutex);
  +        ap_lock(alloc_mutex);
   	blok->h.next = block_freelist;
   	block_freelist = blok;
  -	(void) ap_release_mutex(alloc_mutex);
  +        ap_unlock(alloc_mutex);
       }
       ps->blok = nblok;
       ps->got_a_new_block = 1;
  
  
  

Mime
View raw message