Skip to content

Commit 243e33e

Browse files
committed
Follow up to r1675967 (trunk) resp. r1863202 (1.7.x)
resp. r1863211 (1.6.x): When pool debugging is enabled, make sure we don't try to emit any debug events after the debug log file handle has been closed. Backport of r1675970 from trunk resp. r1863203 from 1.7.x. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1863212 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6df2b8e commit 243e33e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

memory/unix/apr_pools.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,12 @@ static apr_allocator_t *global_allocator = NULL;
636636

637637
#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
638638
static apr_file_t *file_stderr = NULL;
639+
static apr_status_t apr_pool_cleanup_file_stderr(void *data)
640+
{
641+
file_stderr = NULL;
642+
return APR_SUCCESS;
643+
}
644+
639645
#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
640646

641647
/*
@@ -1706,6 +1712,13 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void)
17061712
file_stderr = debug_log;
17071713

17081714
if (file_stderr) {
1715+
/* Add a cleanup handler that sets the debug log file handle
1716+
* to NULL, otherwise we'll try to log the global pool
1717+
* destruction event with predictably disastrous results. */
1718+
apr_pool_cleanup_register(global_pool, NULL,
1719+
apr_pool_cleanup_file_stderr,
1720+
apr_pool_cleanup_null);
1721+
17091722
apr_file_printf(file_stderr,
17101723
"POOL DEBUG: [PID"
17111724
#if APR_HAS_THREADS

0 commit comments

Comments
 (0)