]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: threads: Only consider running threads to end a thread harmeless period
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Apr 2021 09:33:39 +0000 (11:33 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Sat, 17 Apr 2021 09:14:58 +0000 (11:14 +0200)
When a thread ends its harmeless period, we must only consider running
threads when testing threads_want_rdv_mask mask. To do so, we reintroduce
all_threads_mask mask in the bitwise operation (It was removed to fix a
deadlock).

Note that for now it is useless because there is no way to stop threads or
to have threads reserved for another task. But it is safer this way to avoid
bugs in the future.

include/haproxy/thread.h
src/thread.c

index af909f1702f59c8e006fab38e8b702f30a2f80d7..e7d6d2cba290e3582b98a3c6eda34c0b94d66207 100644 (file)
@@ -265,7 +265,7 @@ static inline void thread_harmless_end()
 {
        while (1) {
                HA_ATOMIC_AND(&threads_harmless_mask, ~tid_bit);
-               if (likely((threads_want_rdv_mask & ~tid_bit) == 0))
+               if (likely((threads_want_rdv_mask & all_threads_mask & ~tid_bit) == 0))
                        break;
                thread_harmless_till_end();
        }
index 742e47c09d150eed309e8e6b804f54120aed1b92..07017dd1891a5adc5055025eb11dd2c0680000ab 100644 (file)
@@ -56,7 +56,7 @@ struct lock_stat lock_stats[LOCK_LABELS];
 void thread_harmless_till_end()
 {
                _HA_ATOMIC_OR(&threads_harmless_mask, tid_bit);
-               while (threads_want_rdv_mask & ~tid_bit) {
+               while (threads_want_rdv_mask & all_threads_mask & ~tid_bit) {
                        ha_thread_relax();
                }
 }