]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: haproxy: be sure not to quit too early on soft stop
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Sep 2025 09:26:50 +0000 (11:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 2 Sep 2025 09:33:14 +0000 (11:33 +0200)
The fix in 4a9e3e102e ("BUG/MINOR: haproxy: only tid 0 must not sleep
if got signal") had the nasty side effect of breaking the graceful
reload operations: threads whose id is non-zero could quit too early and
not process incoming traffic, which is visible with broken connections
during reloads. They just need to ignore the the stopping condition
until the signal queue is empty. In any case, it's the thread in charge
of the signal queue which will notify them once it receives the signal.

It was verified that connections are no longer broken with this fix,
and that the issue that required it (#2537, looping threads on reload)
does not re-appear with the reproducer, while it still did without the
fix above. Since the fix above was backported to every stable version,
this one will also have to.

src/haproxy.c

index 4641533cb959af3722842a76faaae5d623fe9394..5d06c286bb1248c6a33397d19a9789c359835463 100644 (file)
@@ -2858,7 +2858,11 @@ void run_poll_loop()
                                wake = 0;
                }
 
-               if (!wake) {
+               /* Note below: threads only check the quit condition when idle,
+                * but for tid>0 we also need to skip that if the signal queue
+                * is non-empty otherwise we risk quitting too early.
+                */
+               if (!wake && !signal_queue_len) {
                        int i;
 
                        if (stopping) {