diff options
-rw-r--r-- | CHANGES | 9 | ||||
-rw-r--r-- | include/apr_pools.h | 9 | ||||
-rw-r--r-- | memory/unix/apr_pools.c | 37 |
3 files changed, 15 insertions, 40 deletions
@@ -1,11 +1,10 @@ -*- coding: utf-8 -*- Changes for APR 2.0.0 - *) apr_allocator, apr_pools: Add apr_allocator_page_size(), - apr_allocator_min_order_set() and apr_pool_alloc_order_set() to - respectively get the (system's) page size in use, set the minimum - allocation size for an allocator and the pool default allocation - size (expressed in 2^order pages). [Yann Ylavic] + *) apr_allocator, apr_pools: Add apr_allocator_page_size() and + apr_allocator_min_order_set() to respectively get the (system's) page size + in use and set the minimum allocation size for an allocator (expressed in + 2^order pages). [Yann Ylavic] *) apr_buckets: Add apr_bucket_file_set_buf_size() which allows to configure the size of the buffer used to read files. [Yann Ylavic] diff --git a/include/apr_pools.h b/include/apr_pools.h index 958d254f3..3020c996a 100644 --- a/include/apr_pools.h +++ b/include/apr_pools.h @@ -171,15 +171,6 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void); */ APR_DECLARE(void) apr_pool_terminate(void); -/** - * Setup the allocation order (in 2^order pages) when creating a pool. - * @param order The order to set - * @return APR_SUCCESS, or APR_EINVAL if @a order above 9. - * @note Default is order-1 (e.g. 8K on systems with 4K pages). - * @remark Should be done at initialization time, never concurrently. - */ -APR_DECLARE(apr_status_t) apr_pool_alloc_order_set(unsigned int order); - /* * Pool creation/destruction */ diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index 79c7eae0e..e3d82d0f7 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -63,10 +63,14 @@ int apr_running_on_valgrind = 0; */ /* - * Recycle up to MAX_INDEX in slots, larger indexes go to - * the sink slot at MAX_INDEX. + * Recycle up to MAX_INDEX in slots, larger indexes go to the + * sink slot at MAX_INDEX, and allocate at least MIN_ALLOC + * bytes (2^order boundaries/pages). */ #define MAX_INDEX 20 +#define MAX_ORDER 9 +static unsigned int min_order = 1; +#define MIN_ALLOC (BOUNDARY_SIZE << min_order) /* * Determines the boundary/page size. @@ -91,16 +95,6 @@ static unsigned int boundary_size; #define GUARDPAGE_SIZE 0 #endif /* APR_ALLOCATOR_GUARD_PAGES */ -/* - * Allocate at least MIN_ALLOC bytes (2^order boundaries/pages), - * and POOL_SIZE bytes for each pool. - */ -#define MAX_ALLOC_ORDER 9 -static unsigned int min_alloc_order = 1; -#define MIN_ALLOC (BOUNDARY_SIZE << min_alloc_order) -static unsigned int pool_alloc_order = 1; -#define POOL_SIZE (BOUNDARY_SIZE << pool_alloc_order) - /* * Timing constants for killing subprocesses * There is a total 3-second delay between sending a SIGINT @@ -529,19 +523,10 @@ APR_DECLARE(apr_size_t) apr_allocator_page_size(void) APR_DECLARE(apr_status_t) apr_allocator_min_order_set(unsigned int order) { - if (order > MAX_ALLOC_ORDER) { - return APR_EINVAL; - } - min_alloc_order = order; - return APR_SUCCESS; -} - -APR_DECLARE(apr_status_t) apr_pool_alloc_order_set(unsigned int order) -{ - if (order > MAX_ALLOC_ORDER) { + if (order > MAX_ORDER) { return APR_EINVAL; } - pool_alloc_order = order; + min_order = order; return APR_SUCCESS; } @@ -1112,7 +1097,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, allocator = parent->allocator; if ((node = allocator_alloc(allocator, - POOL_SIZE - APR_MEMNODE_T_SIZE)) == NULL) { + MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -1206,7 +1191,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, return APR_ENOMEM; } if ((node = allocator_alloc(pool_allocator, - POOL_SIZE - APR_MEMNODE_T_SIZE)) == NULL) { + MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); @@ -1214,7 +1199,7 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool, } } else if ((node = allocator_alloc(pool_allocator, - POOL_SIZE - APR_MEMNODE_T_SIZE)) == NULL) { + MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) { if (abort_fn) abort_fn(APR_ENOMEM); |