From 2d30551a57a8f4ac881336257dd1fcf19cc8d2c4 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 1 Dec 2026 10:28:36 -0500 Subject: [PATCH] mod_proxy_balancer: Set up the balancers before the watchdogs start mod_watchdog's child_init ran first, so mod_proxy_hcheck's watchdog could walk a balancer whose thread mutex was not created yet. (cherry picked from commit 039706610c0695aed904d21ceff9ae0a112b4ee3) --- changes-entries/proxy-balancer-before-watchdog.txt | 3 +++ modules/proxy/mod_proxy_balancer.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changes-entries/proxy-balancer-before-watchdog.txt diff --git a/changes-entries/proxy-balancer-before-watchdog.txt b/changes-entries/proxy-balancer-before-watchdog.txt new file mode 100644 index 00000000000..d3a45748302 --- /dev/null +++ b/changes-entries/proxy-balancer-before-watchdog.txt @@ -0,0 +1,3 @@ + *) mod_proxy_balancer: Set up the balancers in each child before the + watchdogs of mod_proxy_hcheck and mod_proxy_beacon use them. + [Jim Jagielski] diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index e8a5be228c2..3a7b64047dd 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -2056,12 +2056,15 @@ static void ap_proxy_balancer_register_hook(apr_pool_t *p) */ static const char *const aszPred[] = { "mpm_winnt.c", "mod_slotmem_shm.c", NULL}; static const char *const aszPred2[] = { "mod_proxy.c", NULL}; + /* mod_watchdog's child_init starts threads that walk the balancers + * (mod_proxy_hcheck, mod_proxy_beacon): initialize them first. */ + static const char *const aszSucc[] = { "mod_watchdog.c", NULL}; /* manager handler */ APR_REGISTER_OPTIONAL_FN(balancer_manage); ap_hook_post_config(balancer_post_config, aszPred2, NULL, APR_HOOK_MIDDLE); ap_hook_pre_config(balancer_pre_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST); - ap_hook_child_init(balancer_child_init, aszPred, NULL, APR_HOOK_MIDDLE); + ap_hook_child_init(balancer_child_init, aszPred, aszSucc, APR_HOOK_MIDDLE); proxy_hook_pre_request(proxy_balancer_pre_request, NULL, NULL, APR_HOOK_FIRST); proxy_hook_post_request(proxy_balancer_post_request, NULL, NULL, APR_HOOK_FIRST); proxy_hook_canon_handler(proxy_balancer_canon, NULL, NULL, APR_HOOK_FIRST);