- Add new patches (see https://www.haproxy.org/bugs/bugs-1.8.8.html) - Raise patch-level to 03 Signed-off-by: Christian Lachner <gladiac@gmail.com>
48 lines
1.9 KiB
Diff
48 lines
1.9 KiB
Diff
commit 830324444e57c042666b17ac4584352cca85dafd
|
|
Author: Christopher Faulet <cfaulet@haproxy.com>
|
|
Date: Wed May 2 16:58:40 2018 +0200
|
|
|
|
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.
|
|
|
|
(cherry picked from commit 148b16e1ceb819dfcef4c45828121d9cd7474b35)
|
|
Signed-off-by: Willy Tarreau <w@1wt.eu>
|
|
|
|
diff --git a/src/hathreads.c b/src/hathreads.c
|
|
index daf226ce..944a0d5b 100644
|
|
--- a/src/hathreads.c
|
|
+++ b/src/hathreads.c
|
|
@@ -85,7 +85,7 @@ void thread_want_sync()
|
|
/* Returns 1 if no thread has requested a sync. Otherwise, it returns 0. */
|
|
int thread_no_sync()
|
|
{
|
|
- return (threads_want_sync == 0);
|
|
+ return (threads_want_sync == 0UL);
|
|
}
|
|
|
|
/* Returns 1 if the current thread has requested a sync. Otherwise, it returns
|
|
@@ -93,7 +93,7 @@ int thread_no_sync()
|
|
*/
|
|
int thread_need_sync()
|
|
{
|
|
- return (threads_want_sync & tid_bit);
|
|
+ return ((threads_want_sync & tid_bit) != 0UL);
|
|
}
|
|
|
|
/* Thread barrier. Synchronizes all threads at the barrier referenced by
|