]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: soft-stop: let the first stopper only signal other threads
authorWilly Tarreau <w@1wt.eu>
Wed, 13 May 2020 12:30:25 +0000 (14:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 13 May 2020 12:30:25 +0000 (14:30 +0200)
When the first thread stops and wakes others up, it's possible some of
them will also start to wake others in parallel. Let's make give this
notification task to the very first one instead since it's enough and
can reduce the amount of needless (though harmless) wakeup calls.

src/haproxy.c

index c3b7be6491c273cca6619d43643ab9bad54d3b6a..2675bf7157b52fafa85256cb22e531e525c801f9 100644 (file)
@@ -2835,11 +2835,12 @@ void run_poll_loop()
                        int i;
 
                        if (stopping) {
-                               _HA_ATOMIC_OR(&stopping_thread_mask, tid_bit);
-                               /* notify all threads that stopping was just set */
-                               for (i = 0; i < global.nbthread; i++)
-                                       if (((all_threads_mask & ~stopping_thread_mask) >> i) & 1)
-                                               wake_thread(i);
+                               if (_HA_ATOMIC_OR(&stopping_thread_mask, tid_bit) == tid_bit) {
+                                       /* notify all threads that stopping was just set */
+                                       for (i = 0; i < global.nbthread; i++)
+                                               if ((all_threads_mask >> i) & 1)
+                                                       wake_thread(i);
+                               }
                        }
 
                        /* stop when there's nothing left to do */