summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2018-11-23 11:16:29 +0000
committerJoe Orton <jorton@apache.org>2018-11-23 11:16:29 +0000
commit9b367dbac1385133a7d75880e3263109c2a70127 (patch)
treead6956f18587f4469bd2a39ea5a69b8691c60ce5 /test
parent565c30d8f6c520096cecae67500b20b933f611f5 (diff)
downloadapr-9b367dbac1385133a7d75880e3263109c2a70127.tar.gz
* test/testpools.c: Test that it is safe to run a cleanup from a cleanup,
something which httpd relies on working. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1847243 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testpools.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/testpools.c b/test/testpools.c
index 8b0039389..21458ad66 100644
--- a/test/testpools.c
+++ b/test/testpools.c
@@ -104,6 +104,27 @@ static apr_status_t checker_cleanup(void *data)
return data == checker_data ? APR_SUCCESS : APR_EGENERAL;
}
+static char *another_data = "Hello again, world.";
+
+static apr_status_t another_cleanup(void *data)
+{
+ return data == another_data ? APR_SUCCESS : APR_EGENERAL;
+}
+
+/* A few places in httpd modify the cleanup list for a pool while
+ * cleanups are being run. An example is close_listeners_on_exec ->
+ * ap_close_listeners -> ... -> apr_socket_close ->
+ * apr_pool_cleanup_run. This appears to be safe with the current
+ * pools implementation, though perhaps only by chance. If the code is
+ * changed to break this, catch that here - the API can be clarified
+ * and callers fixed. */
+static apr_status_t dodgy_cleanup(void *data)
+{
+ apr_pool_t *p = data;
+
+ return apr_pool_cleanup_run(p, checker_data, checker_cleanup);
+}
+
static void test_cleanups(abts_case *tc, void *data)
{
apr_status_t rv;
@@ -117,6 +138,10 @@ static void test_cleanups(abts_case *tc, void *data)
success_cleanup);
apr_pool_cleanup_register(pchild, NULL, checker_cleanup,
success_cleanup);
+ apr_pool_cleanup_register(pchild, another_data, another_cleanup,
+ another_cleanup);
+ apr_pool_cleanup_register(pchild, pchild, dodgy_cleanup,
+ dodgy_cleanup);
rv = apr_pool_cleanup_run(p, NULL, success_cleanup);
ABTS_ASSERT(tc, "nullop cleanup run OK", rv == APR_SUCCESS);