From: Willy Tarreau Date: Sun, 9 Jun 2019 06:44:19 +0000 (+0200) Subject: MINOR: threads: avoid clearing harmless twice in thread_release() X-Git-Tag: v2.0-dev7~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31cba0d3e04cba229cc7c934b88de3755cf21714;p=thirdparty%2Fhaproxy.git MINOR: threads: avoid clearing harmless twice in thread_release() thread_release() is to be called after thread_isolate(), i.e. when the thread already has its harmless bit cleared. No need to clear it twice, thus avoid calling thread_harmless_end() and directly check the rdv bits then loop on them. --- diff --git a/src/hathreads.c b/src/hathreads.c index 8359dd5ebb..006a0896d9 100644 --- a/src/hathreads.c +++ b/src/hathreads.c @@ -94,7 +94,12 @@ void thread_isolate() void thread_release() { _HA_ATOMIC_AND(&threads_want_rdv_mask, ~tid_bit); - thread_harmless_end(); + while (threads_want_rdv_mask & all_threads_mask) { + _HA_ATOMIC_OR(&threads_harmless_mask, tid_bit); + while (threads_want_rdv_mask & all_threads_mask) + ha_thread_relax(); + HA_ATOMIC_AND(&threads_harmless_mask, ~tid_bit); + } } /* send signal to thread */