]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: startup: make if condition to kill old pids more readable
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 3 Dec 2024 20:13:29 +0000 (21:13 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 6 Dec 2024 11:00:22 +0000 (12:00 +0100)
Update comment and condition. nb_oldpids it's not a pointer, but a signed int,
which keeps the max number of elements in oldpids array. So, it's a good
practice to check, if it's strictly positive here.

src/haproxy.c

index 120822ba6fb9ec514842c0189d5a3fa9504fcab8..34c29d170430f3532b6bee699ebd2d044eba72c1 100644 (file)
@@ -3552,10 +3552,15 @@ int main(int argc, char **argv)
 
        ha_free(&global.chroot);
 
-       /* In master-worker mode master sends TERM to previous workers up to
-        * receiving status READY
+
+       /* In standalone mode send USR1/TERM to the previous worker,
+        * launched with -sf $(cat pidfile).
+        * In master-worker mode, see _send_status(): master process sends
+        * USR1/TERM to previous workers up to receiving status READY from the
+        * worker, which is newly forked. Then master sends USR1 or TERM to previous
+        * master, if it was launched with (-W -D -sf $(cat pidfile).
         */
-       if (!(global.mode & MODE_MWORKER) && nb_oldpids) {
+       if (!(global.mode & MODE_MWORKER) && (nb_oldpids > 0)) {
                nb_oldpids = tell_old_pids(oldpids_sig);
        }