Lines Matching refs:pool

175                                           apr_pool_t *pool)
177 allocator->owner = pool;
495 * pointer to the pointer referencing this pool.
515 apr_memnode_t *self; /* The node containing the pool itself */
519 apr_pool_t *joined; /* the caller has guaranteed that this pool
564 static void pool_destroy_debug(apr_pool_t *pool, const char *file_line);
668 APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t in_size)
676 if (pool->abort_fn)
677 pool->abort_fn(APR_ENOMEM);
681 active = pool->active;
696 if ((node = allocator_alloc(pool->allocator, size)) == NULL) {
697 if (pool->abort_fn)
698 pool->abort_fn(APR_ENOMEM);
711 pool->active = node;
740 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size);
741 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size)
745 if ((mem = apr_palloc(pool, size)) != NULL) {
757 APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool)
762 run_cleanups(&pool->pre_cleanups);
763 pool->pre_cleanups = NULL;
766 * this pool thus this loop is safe and easy.
768 while (pool->child)
769 apr_pool_destroy(pool->child);
772 run_cleanups(&pool->cleanups);
773 pool->cleanups = NULL;
774 pool->free_cleanups = NULL;
777 free_proc_chain(pool->subprocesses);
778 pool->subprocesses = NULL;
781 pool->user_data = NULL;
783 /* Find the node attached to the pool structure, reset it, make
786 active = pool->active = pool->self;
787 active->first_avail = pool->self_first_avail;
793 allocator_free(pool->allocator, active->next);
798 APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool)
804 run_cleanups(&pool->pre_cleanups);
805 pool->pre_cleanups = NULL;
808 * this pool thus this loop is safe and easy.
810 while (pool->child)
811 apr_pool_destroy(pool->child);
814 run_cleanups(&pool->cleanups);
817 free_proc_chain(pool->subprocesses);
819 /* Remove the pool from the parents child list */
820 if (pool->parent) {
824 if ((mutex = apr_allocator_mutex_get(pool->parent->allocator)) != NULL)
828 if ((*pool->ref = pool->sibling) != NULL)
829 pool->sibling->ref = pool->ref;
837 /* Find the block attached to the pool structure. Save a copy of the
838 * allocator pointer, because the pool struct soon will be no more.
840 allocator = pool->allocator;
841 active = pool->self;
845 if (apr_allocator_owner_get(allocator) == pool) {
853 /* Free all the nodes in the pool (including the node holding the
854 * pool struct), by giving them back to the allocator.
858 /* If this pool happens to be the owner of the allocator, free
859 * everything in the allocator (that includes the pool struct
863 if (apr_allocator_owner_get(allocator) == pool) {
873 apr_pool_t *pool;
882 * pool is created, in which case allocator is guaranteed to be
902 pool = (apr_pool_t *)node->first_avail;
903 node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T;
905 pool->allocator = allocator;
906 pool->active = pool->self = node;
907 pool->abort_fn = abort_fn;
908 pool->child = NULL;
909 pool->cleanups = NULL;
910 pool->free_cleanups = NULL;
911 pool->pre_cleanups = NULL;
912 pool->subprocesses = NULL;
913 pool->user_data = NULL;
914 pool->tag = NULL;
917 pool->owner_proc = (apr_os_proc_t)getnlmhandle();
920 if ((pool->parent = parent) != NULL) {
928 if ((pool->sibling = parent->child) != NULL)
929 pool->sibling->ref = &pool->sibling;
931 parent->child = pool;
932 pool->ref = &parent->child;
940 pool->sibling = NULL;
941 pool->ref = NULL;
944 *newpool = pool;
962 apr_pool_t *pool;
991 pool = (apr_pool_t *)node->first_avail;
992 node->first_avail = pool->self_first_avail = (char *)pool + SIZEOF_POOL_T;
994 pool->allocator = pool_allocator;
995 pool->active = pool->self = node;
996 pool->abort_fn = abort_fn;
997 pool->child = NULL;
998 pool->cleanups = NULL;
999 pool->free_cleanups = NULL;
1000 pool->pre_cleanups = NULL;
1001 pool->subprocesses = NULL;
1002 pool->user_data = NULL;
1003 pool->tag = NULL;
1004 pool->parent = NULL;
1005 pool->sibling = NULL;
1006 pool->ref = NULL;
1009 pool->owner_proc = (apr_os_proc_t)getnlmhandle();
1012 pool_allocator->owner = pool;
1013 *newpool = pool;
1024 * block of the pool, starting right at first_avail. If there's
1026 * output is copied over. The new block isn't linked into the pool
1039 apr_pool_t *pool;
1052 apr_pool_t *pool;
1055 pool = ps->pool;
1077 pool->active = node;
1094 node = pool->active;
1097 if ((node = allocator_alloc(pool->allocator, size)) == NULL)
1117 APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
1125 ps.node = active = pool->active;
1126 ps.pool = pool;
1154 allocator_free(pool->allocator, ps.free);
1162 active = pool->active;
1169 pool->active = node;
1191 if (pool->abort_fn)
1192 pool->abort_fn(APR_ENOMEM);
1195 allocator_free(pool->allocator, ps.node);
1208 * Walk the pool tree rooted at pool, depth first. When fn returns
1212 static int apr_pool_walk_tree(apr_pool_t *pool,
1213 int (*fn)(apr_pool_t *pool, void *data),
1219 rv = fn(pool, data);
1224 if (pool->mutex) {
1225 apr_thread_mutex_lock(pool->mutex);
1229 child = pool->child;
1239 if (pool->mutex) {
1240 apr_thread_mutex_unlock(pool->mutex);
1248 static void apr_pool_log_event(apr_pool_t *pool, const char *event,
1271 (unsigned long)apr_pool_num_bytes(pool, 0),
1272 (unsigned long)apr_pool_num_bytes(pool, 1),
1274 pool, pool->tag,
1276 pool->stat_alloc, pool->stat_total_alloc, pool->stat_clear);
1296 pool,
1306 apr_pool_t *pool = (apr_pool_t *)data;
1308 return (pool == parent);
1311 static int apr_pool_is_child_of(apr_pool_t *pool, apr_pool_t *parent)
1316 return apr_pool_walk_tree(parent, pool_is_child_of, pool);
1320 static void apr_pool_check_integrity(apr_pool_t *pool)
1322 /* Rule of thumb: use of the global pool is always
1327 if (pool == global_pool || global_pool == NULL)
1331 * This basically checks to see if the pool being used is still
1332 * a relative to the global pool. If not it was previously
1336 if (!apr_pool_is_child_of(pool, global_pool)) {
1338 apr_pool_log_event(pool, "LIFE",
1347 if (!apr_os_thread_equal(pool->owner, apr_os_thread_current())) {
1349 apr_pool_log_event(pool, "THREAD",
1392 apr_pool_tag(global_pool, "APR global pool");
1458 static void *pool_alloc(apr_pool_t *pool, apr_size_t size)
1464 if (pool->abort_fn)
1465 pool->abort_fn(APR_ENOMEM);
1470 node = pool->nodes;
1474 if (pool->abort_fn)
1475 pool->abort_fn(APR_ENOMEM);
1482 node->next = pool->nodes;
1483 pool->nodes = node;
1491 pool->stat_alloc++;
1492 pool->stat_total_alloc++;
1497 APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size,
1502 apr_pool_check_integrity(pool);
1504 mem = pool_alloc(pool, size);
1507 apr_pool_log_event(pool, "PALLOC", file_line, 1);
1513 APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size,
1518 apr_pool_check_integrity(pool);
1520 mem = pool_alloc(pool, size);
1524 apr_pool_log_event(pool, "PCALLOC", file_line, 1);
1537 static void pool_clear_debug(apr_pool_t *pool, const char *file_line)
1543 run_cleanups(&pool->pre_cleanups);
1544 pool->pre_cleanups = NULL;
1547 * this pool thus this loop is safe and easy.
1549 while (pool->child)
1550 pool_destroy_debug(pool->child, file_line);
1553 run_cleanups(&pool->cleanups);
1554 pool->free_cleanups = NULL;
1555 pool->cleanups = NULL;
1558 if (pool->child)
1562 free_proc_chain(pool->subprocesses);
1563 pool->subprocesses = NULL;
1566 pool->user_data = NULL;
1570 while ((node = pool->nodes) != NULL) {
1571 pool->nodes = node->next;
1583 pool->stat_alloc = 0;
1584 pool->stat_clear++;
1587 APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool,
1594 apr_pool_check_integrity(pool);
1597 apr_pool_log_event(pool, "CLEAR", file_line, 1);
1601 if (pool->parent != NULL)
1602 mutex = pool->parent->mutex;
1608 if (mutex != NULL && mutex != pool->mutex) {
1613 pool_clear_debug(pool, file_line);
1620 if (mutex != pool->mutex) {
1621 (void)apr_thread_mutex_create(&pool->mutex,
1622 APR_THREAD_MUTEX_NESTED, pool);
1630 static void pool_destroy_debug(apr_pool_t *pool, const char *file_line)
1632 apr_pool_check_integrity(pool);
1635 apr_pool_log_event(pool, "DESTROY", file_line, 1);
1638 pool_clear_debug(pool, file_line);
1640 /* Remove the pool from the parents child list */
1641 if (pool->parent) {
1645 if ((mutex = pool->parent->mutex) != NULL)
1649 if ((*pool->ref = pool->sibling) != NULL)
1650 pool->sibling->ref = pool->ref;
1658 if (pool->allocator != NULL
1659 && apr_allocator_owner_get(pool->allocator) == pool) {
1660 apr_allocator_destroy(pool->allocator);
1663 /* Free the pool itself */
1664 free(pool);
1667 APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool,
1670 if (pool->joined) {
1674 apr_pool_log_event(pool, "LIFE",
1680 pool_destroy_debug(pool, file_line);
1689 apr_pool_t *pool;
1706 if ((pool = malloc(SIZEOF_POOL_T)) == NULL) {
1713 memset(pool, 0, SIZEOF_POOL_T);
1715 pool->allocator = allocator;
1716 pool->abort_fn = abort_fn;
1717 pool->tag = file_line;
1718 pool->file_line = file_line;
1720 if ((pool->parent = parent) != NULL) {
1725 if ((pool->sibling = parent->child) != NULL)
1726 pool->sibling->ref = &pool->sibling;
1728 parent->child = pool;
1729 pool->ref = &parent->child;
1737 pool->sibling = NULL;
1738 pool->ref = NULL;
1742 pool->owner = apr_os_thread_current();
1745 pool->owner_proc = (apr_os_proc_t)getnlmhandle();
1757 * the pool having no lock). However, this might actually
1758 * hide problems like creating a child pool of a pool
1761 if ((rv = apr_thread_mutex_create(&pool->mutex,
1762 APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
1763 free(pool);
1771 pool->mutex = parent->mutex;
1775 *newpool = pool;
1778 apr_pool_log_event(pool, "CREATE", file_line, 1);
1798 apr_pool_t *pool;
1803 if ((pool = malloc(SIZEOF_POOL_T)) == NULL) {
1810 memset(pool, 0, SIZEOF_POOL_T);
1812 pool->abort_fn = abort_fn;
1813 pool->tag = file_line;
1814 pool->file_line = file_line;
1817 pool->owner = apr_os_thread_current();
1820 pool->owner_proc = (apr_os_proc_t)getnlmhandle();
1830 pool_allocator->owner = pool;
1832 pool->allocator = pool_allocator;
1834 if (pool->allocator != allocator) {
1842 * the pool having no lock). However, this might actually
1843 * hide problems like creating a child pool of a pool
1846 if ((rv = apr_thread_mutex_create(&pool->mutex,
1847 APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
1848 free(pool);
1854 *newpool = pool;
1857 apr_pool_log_event(pool, "CREATE", file_line, 1);
1890 APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
1895 apr_pool_check_integrity(pool);
1905 if (pool->abort_fn)
1906 pool->abort_fn(APR_ENOMEM);
1916 node = pool->nodes;
1919 if (pool->abort_fn)
1920 pool->abort_fn(APR_ENOMEM);
1925 node->next = pool->nodes;
1926 pool->nodes = node;
1952 static int pool_find(apr_pool_t *pool, void *data)
1958 node = pool->nodes;
1964 *pmem = pool;
1977 void *pool = (void *)mem;
1979 if (apr_pool_walk_tree(global_pool, pool_find, &pool))
1980 return pool;
1985 static int pool_num_bytes(apr_pool_t *pool, void *data)
1991 node = pool->nodes;
2004 APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *pool, int recurse)
2009 pool_num_bytes(pool, &size);
2014 apr_pool_walk_tree(pool, pool_num_bytes, &size);
2019 APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag)
2028 apr_pool_t *pool = global_pool->child;
2031 while (pool) {
2032 if (pool->owner_proc == owner_proc) {
2033 apr_pool_destroy (pool);
2034 pool = global_pool->child;
2037 pool = pool->sibling;
2065 apr_pool_t *pool)
2067 pool->abort_fn = abort_fn;
2070 APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool)
2072 return pool->abort_fn;
2075 APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool)
2078 /* On NetWare, don't return the global_pool, return the application pool
2079 as the top most pool */
2080 if (pool->parent == global_pool)
2081 return pool;
2084 return pool->parent;
2087 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool)
2089 return pool->allocator;
2101 /* Find the pool with the longest lifetime guaranteed by the
2118 APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag)
2120 pool->tag = tag;
2130 apr_pool_t *pool)
2133 apr_pool_check_integrity(pool);
2136 if (pool->user_data == NULL)
2137 pool->user_data = apr_hash_make(pool);
2139 if (apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING) == NULL) {
2140 char *new_key = apr_pstrdup(pool, key);
2141 apr_hash_set(pool->user_data, new_key, APR_HASH_KEY_STRING, data);
2144 apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data);
2148 apr_pool_cleanup_register(pool, data, cleanup, cleanup);
2156 apr_pool_t *pool)
2159 apr_pool_check_integrity(pool);
2162 if (pool->user_data == NULL)
2163 pool->user_data = apr_hash_make(pool);
2165 apr_hash_set(pool->user_data, key, APR_HASH_KEY_STRING, data);
2168 apr_pool_cleanup_register(pool, data, cleanup, cleanup);
2174 apr_pool_t *pool)
2177 apr_pool_check_integrity(pool);
2180 if (pool->user_data == NULL) {
2184 *data = apr_hash_get(pool->user_data, key, APR_HASH_KEY_STRING);
2415 APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *pool, apr_proc_t *proc,
2418 struct process_chain *pc = apr_palloc(pool, sizeof(struct process_chain));
2422 pc->next = pool->subprocesses;
2423 pool->subprocesses = pc;
2530 APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *pool, apr_size_t size,
2533 return apr_palloc(pool, size);
2536 APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *pool, apr_size_t size,
2539 return apr_pcalloc(pool, size);
2542 APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *pool,
2545 apr_pool_clear(pool);
2548 APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *pool,
2551 apr_pool_destroy(pool);
2582 APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size);
2584 APR_DECLARE(void *) apr_palloc(apr_pool_t *pool, apr_size_t size)
2586 return apr_palloc_debug(pool, size, "undefined");
2590 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size);
2592 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *pool, apr_size_t size)
2594 return apr_pcalloc_debug(pool, size, "undefined");
2598 APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool);
2600 APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool)
2602 apr_pool_clear_debug(pool, "undefined");
2606 APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool);
2608 APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool)
2610 apr_pool_destroy_debug(pool, "undefined");