From 7cfd14fb6513a4dd12d14f1b780e2fbc01c4dedd Mon Sep 17 00:00:00 2001 From: Jacquin Antoine Date: Thu, 26 Feb 2026 14:04:47 +0100 Subject: [PATCH] Fix: add missing child_exit hook per architecture.yml - Add reqin_log_child_exit() to close Unix socket on child exit - Register hook with ap_hook_child_exit() - Ensures clean socket cleanup as specified in architecture.yml Co-authored-by: Qwen-Coder --- src/mod_reqin_log.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mod_reqin_log.c b/src/mod_reqin_log.c index f5494f3..5adb720 100644 --- a/src/mod_reqin_log.c +++ b/src/mod_reqin_log.c @@ -591,24 +591,36 @@ static int reqin_log_post_read_request(request_rec *r) static void reqin_log_child_init(apr_pool_t *p, server_rec *s) { (void)p; - + reqin_log_config_t *cfg = get_module_config(s); - + g_child_state.socket_fd = -1; g_child_state.last_connect_attempt = 0; g_child_state.last_error_report = 0; g_child_state.connect_failed = 0; - + if (cfg == NULL || !cfg->enabled || cfg->socket_path == NULL) { return; } - + try_connect(cfg, s); } +static void reqin_log_child_exit(apr_pool_t *p, server_rec *s) +{ + (void)p; + (void)s; + + if (g_child_state.socket_fd >= 0) { + close(g_child_state.socket_fd); + g_child_state.socket_fd = -1; + } +} + static void reqin_log_register_hooks(apr_pool_t *p) { (void)p; ap_hook_post_read_request(reqin_log_post_read_request, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_child_init(reqin_log_child_init, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_child_exit(reqin_log_child_exit, NULL, NULL, APR_HOOK_MIDDLE); }