From e925c61a0e5bbc49368bc32b69d01d9e0305189a Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Fri, 26 Nov 2021 14:43:57 +0100 Subject: [PATCH] BUG/MINOR: mworker: deinit of thread poller was called when not initialized Commit 67e371e ("BUG/MEDIUM: mworker: FD leak of the eventpoll in wait mode") introduced a regression. Upon a reload it tries to deinit the poller per thread, but no poll loop was initialized after loading the configuration. This patch fixes the issue by moving this part of the code in mworker_reload(), since this function will be called only when the poller is fully initialized. This patch must be backported in 2.5. (cherry picked from commit efd954793e60131932c61883d0869c7912a5d12c) Signed-off-by: Christopher Faulet --- src/haproxy.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index a8b257a..e7ef6fc 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -698,7 +698,6 @@ static void mworker_reexec() int i = 0; char *msg = NULL; struct rlimit limit; - struct per_thread_deinit_fct *ptdf; mworker_block_signals(); #if defined(USE_SYSTEMD) @@ -719,11 +718,9 @@ static void mworker_reexec() /* close the listeners FD */ mworker_cli_proxy_stop(); - /* close the poller FD and the thread waker pipe FD */ - list_for_each_entry(ptdf, &per_thread_deinit_list, list) - ptdf->fct(); if (fdtab) deinit_pollers(); + #ifdef HAVE_SSL_RAND_KEEP_RANDOM_DEVICES_OPEN /* close random device FDs */ RAND_keep_random_devices_open(0); @@ -801,9 +798,14 @@ static void mworker_reexec_waitmode() void mworker_reload() { struct mworker_proc *child; + struct per_thread_deinit_fct *ptdf; ha_notice("Reloading HAProxy\n"); + /* close the poller FD and the thread waker pipe FD */ + list_for_each_entry(ptdf, &per_thread_deinit_list, list) + ptdf->fct(); + /* increment the number of reloads */ list_for_each_entry(child, &proc_list, list) { child->reloads++; -- 1.7.10.4