]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker/init: don't reset nb_oldpids in non-mworker cases
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 21 Apr 2021 14:42:18 +0000 (16:42 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 21 Apr 2021 14:42:18 +0000 (16:42 +0200)
This bug affects the peers synchronisation code which rely on the
nb_oldpids variable to synchronize the peer from the old PID.

In the case the process is not started in master-worker mode and tries
to synchronize using the peers, there is a small chance that won't work
because nb_oldpids equals 0.

Fix the bug by setting the variable to 0 only in the case of the
master-worker when not reloaded.

It could also be a problem when trying to synchronize the peers between
2 masters process which should be fixed in another patch.

Bug exists since commit 8a361b5 ("BUG/MEDIUM: mworker: don't reuse PIDs
passed to the master").

Sould be backported as far as 1.8.

src/haproxy.c

index 798173b41a9b53b1d09fcf8e1fba1d1bf89f5174..edc6d6501a23954f676d75e8dc33c5fd0d8e0b36 100644 (file)
@@ -2817,7 +2817,7 @@ int main(int argc, char **argv)
        if ((global.mode & MODE_MWORKER) && !(global.mode & MODE_MWORKER_WAIT))
                mworker_kill_max_reloads(SIGTERM);
 
-       if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) {
+       if ((global.mode & MODE_MWORKER) && (getenv("HAPROXY_MWORKER_REEXEC") == NULL)) {
                nb_oldpids = 0;
                ha_free(&oldpids);
        }