From: Willy Tarreau Date: Tue, 1 Feb 2022 07:47:41 +0000 (+0100) Subject: BUG/MEDIUM: mworker: don't lose the stats socket on failed reload X-Git-Tag: v2.5.2~24 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=b8df64a85120195f40e0f55b9db54c95b72bbdcc;p=haproxy-2.5.git BUG/MEDIUM: mworker: don't lose the stats socket on failed reload In master mode, when the master reexecs itself, it passes the stats socket address via "-x" on the command line. However, the address is first retrieved from the configuration, and only later in the boot sequence the one passed on the command line is considered. As such, some early errors on reload like a missing config file will cause the process to rexec itself with no stats socket address on the command line, preventing the new master from retrieving previous listeners. The right thing to do is to preset the value to the one found on the command line so that it can be preserved across failed reloads. There is no mainline equivalent for this commit because this code was removed from 2.6, which now only uses the socket pair. The patch must be backported to older versions where it applies. --- diff --git a/src/haproxy.c b/src/haproxy.c index 62a2c0f..ee42057 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -656,6 +656,9 @@ int delete_oldpid(int pid) static void get_cur_unixsocket() { + /* get rid of the one found on the command line for now */ + ha_free(&cur_unixsocket); + /* if -x was used, try to update the stat socket if not available anymore */ if (global.cli_fe) { struct bind_conf *bind_conf; @@ -1701,6 +1704,10 @@ static void init(int argc, char **argv) ha_warning("-x option already set, overwriting the value\n"); old_unixsocket = argv[1]; + /* preset it now for early aborts */ + free(cur_unixsocket); + cur_unixsocket = strdup(old_unixsocket); + argv++; argc--; }