]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: threads: Fix the sync point for more than 32 threads
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 2 May 2018 14:58:40 +0000 (16:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 2 May 2018 15:58:36 +0000 (17:58 +0200)
commit148b16e1ceb819dfcef4c45828121d9cd7474b35
tree4650336e22f0405ee07aaa4ef3d8d31968d5343c
parentb119a79fc336f2b6074de1c3113b1682c717985c
BUG/MEDIUM: threads: Fix the sync point for more than 32 threads

In the sync point, to know if a thread has requested a synchronization, we call
the function thread_need_sync(). It should return 1 if yes, otherwise it should
return 0. It is intended to return a signed integer.

But internally, instead of returning 0 or 1, it returns 0 or tid_bit
(threads_want_sync & tid_bit). So, tid_bit is casted in integer. For the first
32 threads, it's ok, because we always check if thread_need_sync() returns
something else than 0. But this is a problem if HAProxy is started with more
than 32 threads, because for threads 33 to 64 (so for tid 32 to 63), their
tid_bit casted to integer are evaluated to 0. So the sync point does not work for
more than 32 threads.

Now, the function thread_need_sync() respects its contract, returning 0 or
1. the function thread_no_sync() has also been updated to avoid any ambiguities.

This patch must be backported in HAProxy 1.8.
src/hathreads.c