svn commit: r1935314 - apr/apr/trunk/memory/unix
[email protected] Sun, 14 Jun 2026 16:38:03 -0000
| Newsgroups | gmane.comp.apache.apr.cvs |
|---|---|
| Message-ID | <178145508320.1796986.14969439115527020707@svn03-he-fi> |
Author: brane
Date: Sun Jun 14 16:38:02 2026
New Revision: 1935314
Log:
Revert r1935301, 1935310 and 1935313, have to test this mor thoroughly.
Sorry about the mess.
Modified:
apr/apr/trunk/memory/unix/apr_pools.c
Modified: apr/apr/trunk/memory/unix/apr_pools.c
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c Sun Jun 14 16:23:39 2026 (r1935313)
+++ apr/apr/trunk/memory/unix/apr_pools.c Sun Jun 14 16:38:02 2026 (r1935314)
@@ -1049,47 +1049,34 @@ APR_DECLARE(void) apr_pool_destroy(apr_p
APR_IF_VALGRIND(VALGRIND_DESTROY_MEMPOOL(pool));
}
-
-/* Create a managed or unmanaged pool. If PARENT is NULL, create an unmanaged
- pool without a parent, otherwise create a managed pool under PARENT. */
-static apr_status_t create_pool(apr_pool_t **newpool,
- apr_pool_t *parent,
- apr_abortfunc_t abort_fn,
- apr_allocator_t *allocator)
+APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
+ apr_pool_t *parent,
+ apr_abortfunc_t abort_fn,
+ apr_allocator_t *allocator)
{
- const int create_unmanaged_pool = (parent == NULL);
- const int need_new_allocator = (allocator == NULL);
apr_pool_t *pool;
apr_memnode_t *node;
- if (create_unmanaged_pool) {
- if (need_new_allocator) {
- if (apr_allocator_create(&allocator) != APR_SUCCESS) {
- if (abort_fn)
- abort_fn(APR_ENOMEM);
+ *newpool = NULL;
- return APR_ENOMEM;
- }
- }
- }
- else {
- if (!abort_fn)
- abort_fn = parent->abort_fn;
+ if (!parent)
+ parent = global_pool;
- if (need_new_allocator)
- allocator = parent->allocator;
- }
+ /* parent will always be non-NULL here except the first time a
+ * pool is created, in which case allocator is guaranteed to be
+ * non-NULL. */
+
+ if (!abort_fn && parent)
+ abort_fn = parent->abort_fn;
+
+ if (allocator == NULL)
+ allocator = parent->allocator;
if ((node = allocator_alloc(allocator,
MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {
if (abort_fn)
abort_fn(APR_ENOMEM);
- if (create_unmanaged_pool && need_new_allocator && allocator != NULL) {
- /* We created a new allocator but can't allocate, so destroy it. */
- apr_allocator_destroy(allocator);
- }
-
return APR_ENOMEM;
}
@@ -1125,72 +1112,93 @@ static apr_status_t create_pool(apr_pool
pool->user_data = NULL;
pool->tag = NULL;
- if (create_unmanaged_pool) {
- if (need_new_allocator)
- allocator->owner = pool;
- }
- else {
- if ((pool->parent = parent) != NULL) {
- allocator_lock(parent->allocator);
+ if ((pool->parent = parent) != NULL) {
+ allocator_lock(parent->allocator);
- if ((pool->sibling = parent->child) != NULL)
- pool->sibling->ref = &pool->sibling;
+ if ((pool->sibling = parent->child) != NULL)
+ pool->sibling->ref = &pool->sibling;
- parent->child = pool;
- pool->ref = &parent->child;
+ parent->child = pool;
+ pool->ref = &parent->child;
- allocator_unlock(parent->allocator);
- }
- else {
- pool->sibling = NULL;
- pool->ref = NULL;
- }
+ allocator_unlock(parent->allocator);
+ }
+ else {
+ pool->sibling = NULL;
+ pool->ref = NULL;
}
pool_concurrency_init(pool);
+
*newpool = pool;
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
- apr_pool_t *parent,
- apr_abortfunc_t abort_fn,
- apr_allocator_t *allocator)
+APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
+ apr_abortfunc_t abort_fn,
+ apr_allocator_t *allocator)
{
+ apr_pool_t *pool;
+ apr_memnode_t *node;
+ apr_allocator_t *pool_allocator;
+
*newpool = NULL;
- if (!parent)
- parent = global_pool;
+ if (!apr_pools_initialized)
+ return APR_ENOPOOL;
+ if ((pool_allocator = allocator) == NULL) {
+ if (apr_allocator_create(&pool_allocator) != APR_SUCCESS) {
+ if (abort_fn)
+ abort_fn(APR_ENOMEM);
- /* parent will always be non-NULL here except the first time a
- * pool is created, in which case allocator is guaranteed to be
- * non-NULL. */
+ return APR_ENOMEM;
+ }
+ if ((node = allocator_alloc(pool_allocator,
+ MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {
+ if (abort_fn)
+ abort_fn(APR_ENOMEM);
+
+ apr_allocator_destroy(pool_allocator);
- if (parent == NULL && allocator == NULL) {
+ return APR_ENOMEM;
+ }
+ }
+ else if ((node = allocator_alloc(pool_allocator,
+ MIN_ALLOC - APR_MEMNODE_T_SIZE)) == NULL) {
if (abort_fn)
- abort_fn(APR_ENOPOOL);
+ abort_fn(APR_ENOMEM);
- return APR_ENOPOOL;
+ return APR_ENOMEM;
}
- return create_pool(newpool, parent, abort_fn, allocator);
-}
+ node->next = node;
+ node->ref = &node->next;
-APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
- apr_abortfunc_t abort_fn,
- apr_allocator_t *allocator)
-{
- *newpool = NULL;
+ pool = (apr_pool_t *)node->first_avail;
+ node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T;
- if (!apr_pools_initialized) {
- if (abort_fn)
- abort_fn(APR_ENOPOOL);
+ pool->allocator = pool_allocator;
+ pool->active = pool->self = node;
+ pool->abort_fn = abort_fn;
+ pool->child = NULL;
+ pool->cleanups = NULL;
+ pool->free_cleanups = NULL;
+ pool->pre_cleanups = NULL;
+ pool->subprocesses = NULL;
+ pool->user_data = NULL;
+ pool->tag = NULL;
+ pool->parent = NULL;
+ pool->sibling = NULL;
+ pool->ref = NULL;
- return APR_ENOPOOL;
- }
+ if (!allocator)
+ pool_allocator->owner = pool;
- return create_pool(newpool, NULL, abort_fn, allocator);
+ pool_concurrency_init(pool);
+ *newpool = pool;
+
+ return APR_SUCCESS;
}
/*