summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Jung <rjung@apache.org>2019-07-17 11:45:29 +0000
committerRainer Jung <rjung@apache.org>2019-07-17 11:45:29 +0000
commit24b218016e875e2dc0c87ce7b7341f00e37e4753 (patch)
tree17081c4dad60cebe1cd7ca0c1369d1ec43d07b30
parent1e48e704fe30c51f29d90c117e601e8df270d743 (diff)
downloadapr-24b218016e875e2dc0c87ce7b7341f00e37e4753.tar.gz
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
-rw-r--r--memory/unix/apr_pools.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index 9fdd00129..eb173c88e 100644
--- a/memory/unix/apr_pools.c
+++ b/memory/unix/apr_pools.c
@@ -636,6 +636,12 @@ static apr_allocator_t *global_allocator = NULL;
#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
static apr_file_t *file_stderr = NULL;
+static apr_status_t apr_pool_cleanup_file_stderr(void *data)
+{
+ file_stderr = NULL;
+ return APR_SUCCESS;
+}
+
#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
/*
@@ -1706,6 +1712,13 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void)
file_stderr = debug_log;
if (file_stderr) {
+ /* Add a cleanup handler that sets the debug log file handle
+ * to NULL, otherwise we'll try to log the global pool
+ * destruction event with predictably disastrous results. */
+ apr_pool_cleanup_register(global_pool, NULL,
+ apr_pool_cleanup_file_stderr,
+ apr_pool_cleanup_null);
+
apr_file_printf(file_stderr,
"POOL DEBUG: [PID"
#if APR_HAS_THREADS