]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: don't use _getsocks in wait mode
authorWilliam Lallemand <wlallemand@haproxy.org>
Fri, 7 Jan 2022 17:19:42 +0000 (18:19 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 7 Jan 2022 17:44:27 +0000 (18:44 +0100)
Since version 2.5 the master is automatically re-executed in wait-mode
when the config is successfully loaded, puting corner cases of the wait
mode in plain sight.

When using the -x argument and with the right timing, the master will
try to get the FDs again in wait mode even through it's not needed
anymore, which will harm the worker by removing its listeners.

However, if it fails, (and it's suppose to, sometimes), the
master will exit with EXIT_FAILURE because it does not have the
MODE_MWORKER flag, but only the MODE_MWORKER_WAIT flag. With the
consequence of killing the workers.

This patch fixes the issue by restricting the use of _getsocks to some
modes.

This patch must be backported in every version supported, even through
the impact should me more harmless in version prior to 2.5.

src/haproxy.c

index cdd1ae8342763e9560c58a54bb8f14668d70deec..17108b52f934a47501bf7cc772840e7f6c2c7da3 100644 (file)
@@ -2988,7 +2988,12 @@ int main(int argc, char **argv)
 #endif
        }
 
-       if (old_unixsocket) {
+       /* Try to get the listeners FD from the previous process using
+        * _getsocks on the stat socket, it must never been done in wait mode
+        * and check mode
+        */
+       if (old_unixsocket &&
+           !(global.mode & (MODE_MWORKER_WAIT|MODE_CHECK|MODE_CHECK_CONDITION))) {
                if (strcmp("/dev/null", old_unixsocket) != 0) {
                        if (sock_get_old_sockets(old_unixsocket) != 0) {
                                ha_alert("Failed to get the sockets from the old process!\n");