httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/lib apr_pools.c
Date Mon, 13 Mar 2000 21:46:43 GMT
rbb         00/03/13 13:46:43

  Modified:    src/lib/apr/lib apr_pools.c
  Log:
  If we don't have threads in APR, we can't create INTRAPROCESS locks.
  This also keeps us from trying to use thread locks when we aren't using
  threads.  Should be a small performance improvement.
  
  Revision  Changes    Path
  1.34      +28 -1     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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- apr_pools.c	2000/03/10 00:06:12	1.33
  +++ apr_pools.c	2000/03/13 21:46:42	1.34
  @@ -230,8 +230,10 @@
    */
   static union block_hdr *block_freelist = NULL;
   
  +#if APR_HAS_THREADS
   static ap_lock_t *alloc_mutex;
   static ap_lock_t *spawn_mutex;
  +#endif
   
   #ifdef POOL_DEBUG
   static char *known_stack_point;
  @@ -361,7 +363,9 @@
   	return;			/* Sanity check --- freeing empty pool? */
       }
   
  +#if APR_HAS_THREADS
       ap_lock(alloc_mutex);
  +#endif
       old_free_list = block_freelist;
       block_freelist = blok;
   
  @@ -409,7 +413,9 @@
       num_blocks_freed += num_blocks;
   #endif /* ALLOC_STATS */
   
  +#if APR_HAS_THREADS
       ap_unlock(alloc_mutex);
  +#endif /* APR_HAS_THREADS */
   #endif /* ALLOC_USE_MALLOC */
   }
   
  @@ -499,7 +505,9 @@
   
       ap_block_alarms();
   
  +#if APR_HAS_THREADS
       ap_lock(alloc_mutex);
  +#endif
   
       blok = new_block(POOL_HDR_BYTES, apr_abort);
       new_pool = (ap_pool_t *) blok->h.first_avail;
  @@ -521,7 +529,9 @@
   	p->sub_pools = new_pool;
       }
   
  +#if APR_HAS_THREADS
       ap_unlock(alloc_mutex);
  +#endif
       ap_unblock_alarms();
   
       return new_pool;
  @@ -565,6 +575,7 @@
       known_stack_point = &s;
       stack_var_init(&s);
   #endif
  +#if APR_HAS_THREADS
       status1 = ap_create_lock(&alloc_mutex, APR_MUTEX, APR_INTRAPROCESS,
                      NULL, NULL);
       status2 = ap_create_lock(&spawn_mutex, APR_MUTEX, APR_INTRAPROCESS,
  @@ -572,6 +583,7 @@
       if (status1 != APR_SUCCESS || status2 != APR_SUCCESS) {
           return NULL;
       }
  +#endif
   
       permanent_pool = ap_make_sub_pool(NULL, NULL);
   #ifdef ALLOC_STATS
  @@ -635,7 +647,9 @@
   {
       ap_block_alarms();
       ap_clear_real_pool(a);
  +#if APR_HAS_THREADS
       ap_lock(alloc_mutex);
  +#endif
   
       if (a->parent) {
   	if (a->parent->sub_pools == a) {
  @@ -648,8 +662,9 @@
   	    a->sub_next->sub_prev = a->sub_prev;
   	}
       }
  +#if APR_HAS_THREADS
       ap_unlock(alloc_mutex);
  -
  +#endif
       free_blocks(a->first);
       ap_unblock_alarms();
   }
  @@ -855,7 +870,9 @@
   
       ap_block_alarms();
   
  +#if APR_HAS_THREADS
       ap_lock(alloc_mutex);
  +#endif
   
       blok = new_block(size, c->apr_abort);
       a->last->h.next = blok;
  @@ -864,7 +881,9 @@
       blok->h.owning_pool = a;
   #endif
   
  +#if APR_HAS_THREADS
       ap_unlock(alloc_mutex);
  +#endif
   
       ap_unblock_alarms();
   
  @@ -1000,9 +1019,13 @@
       cur_len = strp - blok->h.first_avail;
   
       /* must try another blok */
  +#if APR_HAS_THREADS
       ap_lock(alloc_mutex);
  +#endif
       nblok = new_block(2 * cur_len, NULL);
  +#if APR_HAS_THREADS
       ap_unlock(alloc_mutex);
  +#endif
       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 */
  @@ -1011,10 +1034,14 @@
       /* 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);
  +#if APR_HAS_THREADS
           ap_lock(alloc_mutex);
  +#endif
   	blok->h.next = block_freelist;
   	block_freelist = blok;
  +#if APR_HAS_THREADS
           ap_unlock(alloc_mutex);
  +#endif
       }
       ps->blok = nblok;
       ps->got_a_new_block = 1;
  
  
  

Mime
View raw message