apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/misc/unix start.c
Date Sun, 31 Dec 2000 18:05:00 GMT
rbb         00/12/31 10:05:00

  Modified:    .        CHANGES
               include  apr_pools.h
               lib      apr_pools.c
               misc/unix start.c
  Log:
  Begin to remove the ability to allocate out of NULL pools.  The first
  problem to solve, is that we need an apr_lock in order to allocate
  pools, so that we can lock things out when allocating.  So, how do we
  allocate locks without a pool to allocate from?  The answer is to create
  a global_apr_pool, which is a bootstrapping pool.  There should NEVER
  be a sub-pool off this pool, and it is static to an APR file.  This is
  only used to allow us to allocate the locks cleanly, without using the
  NULL pool hack.
  
  Revision  Changes    Path
  1.33      +9 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- CHANGES	2000/12/30 18:31:36	1.32
  +++ CHANGES	2000/12/31 18:04:59	1.33
  @@ -1,5 +1,14 @@
   Changes with APR b1
   
  +  *) Begin to remove the ability to allocate out of NULL pools.  The first
  +     problem to solve, is that we need an apr_lock in order to allocate
  +     pools, so that we can lock things out when allocating.  So, how do we
  +     allocate locks without a pool to allocate from?  The answer is to create
  +     a global_apr_pool, which is a bootstrapping pool.  There should NEVER
  +     be a sub-pool off this pool, and it is static to an APR file.  This is
  +     only used to allow us to allocate the locks cleanly, without using the
  +     NULL pool hack.  [Ryan Bloom]
  +
     *) Fix a logic error in the poll code when implemented using select.
        [Nick Caruso <ncaruso@gamesville.com>]
   
  
  
  
  1.37      +8 -2      apr/include/apr_pools.h
  
  Index: apr_pools.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_pools.h,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- apr_pools.h	2000/12/04 06:22:29	1.36
  +++ apr_pools.h	2000/12/31 18:04:59	1.37
  @@ -209,17 +209,23 @@
   
   /**
    * Setup all of the internal structures required to use pools
  + * @parm globalp The apr global pool, used to allocate APR structures
  + *               before any other pools are created.  This pool should not
  + *               ever be used outside of APR.
    * @tip Programs do NOT need to call this directly.  APR will call this
    *      automatically from apr_initialize. 
    */
  -apr_status_t apr_init_alloc(void);	/* Set up everything */
  +apr_status_t apr_init_alloc(apr_pool_t *globalp);	/* Set up everything */
   
   /**
    * Tear down all of the internal structures required to use pools
  + * @parm globalp The apr global pool, used to allocate APR structures
  + *               before any other pools are created.  This pool should not
  + *               ever be used outside of APR.
    * @tip Programs do NOT need to call this directly.  APR will call this
    *      automatically from apr_terminate. 
    */
  -void apr_term_alloc(void);        /* Tear down everything */
  +void apr_term_alloc(apr_pool_t *globalp);        /* Tear down everything */
    
   /* pool functions */
   
  
  
  
  1.75      +26 -13    apr/lib/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/lib/apr_pools.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- apr_pools.c	2000/12/06 20:02:34	1.74
  +++ apr_pools.c	2000/12/31 18:04:59	1.75
  @@ -469,7 +469,9 @@
   
   
   #if APR_HAS_THREADS
  -    apr_lock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_lock(alloc_mutex);
  +    }
   #endif
   
       blok = new_block(POOL_HDR_BYTES, apr_abort);
  @@ -496,7 +498,9 @@
       }
   
   #if APR_HAS_THREADS
  -    apr_unlock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_unlock(alloc_mutex);
  +    }
   #endif
   
       return new_pool;
  @@ -662,7 +666,7 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_init_alloc(void)
  +apr_status_t apr_init_alloc(apr_pool_t *globalp)
   {
   #if APR_HAS_THREADS
       apr_status_t status;
  @@ -675,13 +679,13 @@
   #endif
   #if APR_HAS_THREADS
       status = apr_create_lock(&alloc_mutex, APR_MUTEX, APR_INTRAPROCESS,
  -                   NULL, NULL);
  +                   NULL, globalp);
       if (status != APR_SUCCESS) {
           apr_destroy_lock(alloc_mutex); 
           return status;
       }
       status = apr_create_lock(&spawn_mutex, APR_MUTEX, APR_INTRAPROCESS,
  -                   NULL, NULL);
  +                   NULL, globalp);
       if (status != APR_SUCCESS) {
           apr_destroy_lock(spawn_mutex); 
           return status;
  @@ -695,12 +699,13 @@
       return APR_SUCCESS;
   }
   
  -void apr_term_alloc(void)
  +void apr_term_alloc(apr_pool_t *globalp)
   {
   #if APR_HAS_THREADS
       apr_destroy_lock(alloc_mutex);
       apr_destroy_lock(spawn_mutex);
   #endif
  +    apr_destroy_pool(globalp);
   }
   
   /* We only want to lock the mutex if we are being called from apr_clear_pool.
  @@ -748,7 +753,9 @@
   {
       apr_clear_pool(a);
   #if APR_HAS_THREADS
  -    apr_lock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_lock(alloc_mutex);
  +    }
   #endif
   
       if (a->parent) {
  @@ -763,7 +770,9 @@
   	}
       }
   #if APR_HAS_THREADS
  -    apr_unlock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_unlock(alloc_mutex);
  +    }
   #endif
       free_blocks(a->first);
   }
  @@ -928,15 +937,15 @@
       char *first_avail;
       char *new_first_avail;
   
  +    nclicks = 1 + ((reqsize - 1) / CLICK_SZ);
  +    size = nclicks * CLICK_SZ;
  +
   
       if (a == NULL) {
           return malloc(reqsize);
       }
   
   
  -    nclicks = 1 + ((reqsize - 1) / CLICK_SZ);
  -    size = nclicks * CLICK_SZ;
  -
       /* First, see if we have space in the block most recently
        * allocated to this pool
        */
  @@ -961,7 +970,9 @@
       /* Nope --- get a new one that's guaranteed to be big enough */
   
   #if APR_HAS_THREADS
  -    apr_lock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_lock(alloc_mutex);
  +    }
   #endif
   
       blok = new_block(size, a->apr_abort);
  @@ -972,7 +983,9 @@
   #endif
   
   #if APR_HAS_THREADS
  -    apr_unlock(alloc_mutex);
  +    if (alloc_mutex) {
  +        apr_unlock(alloc_mutex);
  +    }
   #endif
   
       first_avail = blok->h.first_avail;
  
  
  
  1.45      +7 -3      apr/misc/unix/start.c
  
  Index: start.c
  ===================================================================
  RCS file: /home/cvs/apr/misc/unix/start.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- start.c	2000/12/06 20:02:35	1.44
  +++ start.c	2000/12/31 18:04:59	1.45
  @@ -61,8 +61,8 @@
   
   
   static int initialized = 0;
  +static apr_pool_t *global_apr_pool;
   
  -
   apr_status_t apr_initialize(void)
   {
       apr_status_t status;
  @@ -76,6 +76,10 @@
           return APR_SUCCESS;
       }
   
  +    if (apr_create_pool(&global_apr_pool, NULL) != APR_SUCCESS) {
  +        return APR_ENOPOOL;
  +    }
  +
   #if !defined(BEOS) && !defined(OS2) && !defined(WIN32)
       apr_unix_setup_lock();
   #elif defined WIN32
  @@ -90,7 +94,7 @@
           return APR_EEXIST;
       }
   #endif
  -    status = apr_init_alloc();
  +    status = apr_init_alloc(global_apr_pool);
       return status;
   }
   
  @@ -100,7 +104,7 @@
       if (initialized) {
           return;
       }
  -    apr_term_alloc();
  +    apr_term_alloc(global_apr_pool);
   }
   
   apr_status_t apr_set_abort(int (*apr_abort)(int retcode), apr_pool_t *cont)
  
  
  

Mime
View raw message