apr/Follow-up-to-r1675967-trunk-resp.-r1863202-1.7.x.patch
2020-06-30 17:26:36 +08:00

50 lines
1.7 KiB
Diff

From 9032d8c633dbc0f6fe2cd3358f767f088ffbf1ef Mon Sep 17 00:00:00 2001
From: Rainer Jung <rjung@apache.org>
Date: Wed, 17 Jul 2019 11:31:02 +0000
Subject: [PATCH] Follow up to r1675967 (trunk) resp. r1863202 (1.7.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.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1863203 13f79535-47bb-0310-9956-ffa450edef68
---
memory/unix/apr_pools.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c
index 9fdd001..eb173c8 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
--
1.8.3.1