From: William Lallemand Date: Mon, 20 Nov 2023 09:49:05 +0000 (+0100) Subject: BUG/MINOR: startup: set GTUNE_SOCKET_TRANSFER correctly X-Git-Tag: v2.9-dev11~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef9a1957424e9fcf147abe4fcceff5d6c809f945;p=thirdparty%2Fhaproxy.git BUG/MINOR: startup: set GTUNE_SOCKET_TRANSFER correctly This bug was forbidding the GTUNE_SOCKET_TRANSFER option to be set when haproxy is neither in daemon mode nor in mworker mode. So it basically only impacts the foreground mode. The fix moves the code outside the 'if (global.mode & (MODE_DAEMON | MODE_MWORKER | MODE_MWORKER_WAIT))' condition. Bug was introduced with 7f80eb23 ("MEDIUM: proxy: zombify proxies only when the expose-fd socket is bound"). Must be backported in every stable version. --- diff --git a/src/haproxy.c b/src/haproxy.c index 1fa7b801dd..33e8ae8671 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3750,22 +3750,6 @@ int main(int argc, char **argv) ha_free(&global.chroot); set_identity(argv[0]); - /* pass through every cli socket, and check if it's bound to - * the current process and if it exposes listeners sockets. - * Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork. - * */ - - if (global.cli_fe) { - struct bind_conf *bind_conf; - - list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) { - if (bind_conf->level & ACCESS_FD_LISTENERS) { - global.tune.options |= GTUNE_SOCKET_TRANSFER; - break; - } - } - } - /* * This is only done in daemon mode because we might want the * logs on stdout in mworker mode. If we're NOT in QUIET mode, @@ -3787,6 +3771,22 @@ int main(int argc, char **argv) fork_poller(); } + /* pass through every cli socket, and check if it's bound to + * the current process and if it exposes listeners sockets. + * Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork. + * */ + + if (global.cli_fe) { + struct bind_conf *bind_conf; + + list_for_each_entry(bind_conf, &global.cli_fe->conf.bind, by_fe) { + if (bind_conf->level & ACCESS_FD_LISTENERS) { + global.tune.options |= GTUNE_SOCKET_TRANSFER; + break; + } + } + } + /* Note that here we can't be in the parent/master anymore */ #if !defined(USE_THREAD) && defined(USE_CPU_AFFINITY) if (ha_cpuset_count(&cpu_map[0].thread[0])) { /* only do this if the process has a CPU map */