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); }