Author: covener
Date: Fri Aug 7 14:16:46 2026
New Revision: 1936970
Log:
use sub-pools for memcache tests
so they can be cleaned up while sigpipe is still
ignored (quit on closed socket?)
Modified:
apr/apr/trunk/test/testmemcache.c
Modified: apr/apr/trunk/test/testmemcache.c
==============================================================================
--- apr/apr/trunk/test/testmemcache.c Fri Aug 7 14:11:58 2026 (r1936969)
+++ apr/apr/trunk/test/testmemcache.c Fri Aug 7 14:16:46 2026 (r1936970)
@@ -677,6 +677,7 @@ static void test_connection_validation(a
apr_status_t rv;
apr_memcache_t *memcache;
apr_memcache_server_t *memserver;
+ apr_pool_t *mc_pool;
char *result;
apr_procattr_t *procattr;
apr_proc_t proc;
@@ -722,10 +723,18 @@ static void test_connection_validation(a
/* Wait for the mock memcached to start */
apr_sleep(apr_time_from_sec(2));
- rv = apr_memcache_create(p, 1, 0, &memcache);
+ /*
+ * Use a sub-pool for the memcache objects so the reslist (and its
+ * mc_conn_destruct callbacks, which write to the now-dead socket) is
+ * torn down before we restore the SIGPIPE handler.
+ */
+ rv = apr_pool_create(&mc_pool, p);
+ ABTS_ASSERT(tc, "pool create failed", rv == APR_SUCCESS);
+
+ rv = apr_memcache_create(mc_pool, 1, 0, &memcache);
ABTS_ASSERT(tc, "memcache create failed", rv == APR_SUCCESS);
- rv = apr_memcache_server_create(p, MOCK_HOST, MOCK_PORT, 0, 1, 1,
+ rv = apr_memcache_server_create(mc_pool, MOCK_HOST, MOCK_PORT, 0, 1, 1,
apr_time_from_sec(60), &memserver);
ABTS_ASSERT(tc, "server create failed", rv == APR_SUCCESS);
@@ -741,6 +750,12 @@ static void test_connection_validation(a
rv = apr_memcache_version(memserver, p, &result);
ABTS_ASSERT(tc, "Couldn't get version after connection shutdown", rv == APR_SUCCESS);
+ /*
+ * Destroy the pool while SIGPIPE is still ignored: mc_conn_destruct sends
+ * "quit\r\n" to the dead socket which would otherwise raise SIGPIPE.
+ */
+ apr_pool_destroy(mc_pool);
+
#ifdef SIGPIPE
/* Restore old SIGPIPE handler */
apr_signal(SIGPIPE, old_action);
@@ -762,6 +777,7 @@ static apr_status_t run_mock_version(abt
apr_status_t rv;
apr_memcache_t *memcache;
apr_memcache_server_t *memserver;
+ apr_pool_t *mc_pool;
char *result = NULL;
const char *args[4];
int exitcode;
@@ -789,9 +805,17 @@ static apr_status_t run_mock_version(abt
apr_sleep(apr_time_from_sec(2));
- rv = apr_memcache_create(p, 1, 0, &memcache);
+ /*
+ * Use a sub-pool for the memcache objects so the reslist (and its
+ * mc_conn_destruct callbacks, which write to the now-dead socket) is
+ * torn down before the caller restores the SIGPIPE handler.
+ */
+ rv = apr_pool_create(&mc_pool, p);
+ ABTS_ASSERT(tc, "pool create failed", rv == APR_SUCCESS);
+
+ rv = apr_memcache_create(mc_pool, 1, 0, &memcache);
ABTS_ASSERT(tc, "memcache create failed", rv == APR_SUCCESS);
- rv = apr_memcache_server_create(p, MOCK_HOST, MOCK_PORT, 0, 1, 1,
+ rv = apr_memcache_server_create(mc_pool, MOCK_HOST, MOCK_PORT, 0, 1, 1,
apr_time_from_sec(60), &memserver);
ABTS_ASSERT(tc, "server create failed", rv == APR_SUCCESS);
rv = apr_memcache_add_server(memcache, memserver);
@@ -799,6 +823,13 @@ static apr_status_t run_mock_version(abt
rv = apr_memcache_version(memserver, p, &result);
+ /*
+ * Destroy the sub-pool before waiting for the process: this tears down
+ * the reslist and its mc_conn_destruct callbacks while SIGPIPE is still
+ * ignored by the caller (test_version_responses).
+ */
+ apr_pool_destroy(mc_pool);
+
apr_proc_wait(&proc, &exitcode, &why, APR_WAIT);
if (result_out) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.