@@ -590,6 +590,7 @@ struct apr_pool_t {
590590 apr_os_thread_t owner ;
591591 apr_thread_mutex_t * mutex ;
592592#endif /* APR_HAS_THREADS */
593+ int unmanaged ;
593594#endif /* APR_POOL_DEBUG */
594595#ifdef NETWARE
595596 apr_os_proc_t owner_proc ;
@@ -1605,7 +1606,8 @@ static void apr_pool_check_lifetime(apr_pool_t *pool)
16051606 * people have searched for the top level parent and
16061607 * started to use that...
16071608 */
1608- if (pool == global_pool || global_pool == NULL )
1609+ if (pool == global_pool || global_pool == NULL
1610+ || (pool -> parent == NULL && pool -> unmanaged ))
16091611 return ;
16101612
16111613 /* Lifetime
@@ -2035,6 +2037,22 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
20352037 pool -> owner_proc = (apr_os_proc_t )getnlmhandle ();
20362038#endif /* defined(NETWARE) */
20372039
2040+ if ((pool -> parent = parent ) != NULL ) {
2041+ pool_lock (parent );
2042+
2043+ if ((pool -> sibling = parent -> child ) != NULL )
2044+ pool -> sibling -> ref = & pool -> sibling ;
2045+
2046+ parent -> child = pool ;
2047+ pool -> ref = & parent -> child ;
2048+
2049+ pool_unlock (parent );
2050+ }
2051+ else {
2052+ pool -> sibling = NULL ;
2053+ pool -> ref = NULL ;
2054+ }
2055+
20382056#if APR_HAS_THREADS
20392057 if (parent == NULL || parent -> allocator != allocator ) {
20402058 apr_status_t rv ;
@@ -2058,22 +2076,6 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
20582076 }
20592077#endif /* APR_HAS_THREADS */
20602078
2061- if ((pool -> parent = parent ) != NULL ) {
2062- pool_lock (parent );
2063-
2064- if ((pool -> sibling = parent -> child ) != NULL )
2065- pool -> sibling -> ref = & pool -> sibling ;
2066-
2067- parent -> child = pool ;
2068- pool -> ref = & parent -> child ;
2069-
2070- pool_unlock (parent );
2071- }
2072- else {
2073- pool -> sibling = NULL ;
2074- pool -> ref = NULL ;
2075- }
2076-
20772079#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE )
20782080 apr_pool_log_event (pool , "CREATE" , file_line , 1 );
20792081#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */
@@ -2111,10 +2113,29 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpoo
21112113
21122114 memset (pool , 0 , SIZEOF_POOL_T );
21132115
2116+ pool -> unmanaged = 1 ;
21142117 pool -> abort_fn = abort_fn ;
21152118 pool -> tag = file_line ;
21162119 pool -> file_line = file_line ;
21172120
2121+ #if APR_HAS_THREADS
2122+ pool -> owner = apr_os_thread_current ();
2123+ #endif /* APR_HAS_THREADS */
2124+ #ifdef NETWARE
2125+ pool -> owner_proc = (apr_os_proc_t )getnlmhandle ();
2126+ #endif /* defined(NETWARE) */
2127+
2128+ if ((pool_allocator = allocator ) == NULL ) {
2129+ apr_status_t rv ;
2130+ if ((rv = apr_allocator_create (& pool_allocator )) != APR_SUCCESS ) {
2131+ if (abort_fn )
2132+ abort_fn (rv );
2133+ return rv ;
2134+ }
2135+ pool_allocator -> owner = pool ;
2136+ }
2137+ pool -> allocator = pool_allocator ;
2138+
21182139#if APR_HAS_THREADS
21192140 {
21202141 apr_status_t rv ;
@@ -2135,24 +2156,6 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpoo
21352156 }
21362157#endif /* APR_HAS_THREADS */
21372158
2138- #if APR_HAS_THREADS
2139- pool -> owner = apr_os_thread_current ();
2140- #endif /* APR_HAS_THREADS */
2141- #ifdef NETWARE
2142- pool -> owner_proc = (apr_os_proc_t )getnlmhandle ();
2143- #endif /* defined(NETWARE) */
2144-
2145- if ((pool_allocator = allocator ) == NULL ) {
2146- apr_status_t rv ;
2147- if ((rv = apr_allocator_create (& pool_allocator )) != APR_SUCCESS ) {
2148- if (abort_fn )
2149- abort_fn (rv );
2150- return rv ;
2151- }
2152- pool_allocator -> owner = pool ;
2153- }
2154- pool -> allocator = pool_allocator ;
2155-
21562159#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE )
21572160 apr_pool_log_event (pool , "CREATEU" , file_line , 1 );
21582161#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */
0 commit comments