mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-02 17:41:47 +00:00
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.
This commit is contained in:
parent
b119a79fc3
commit
148b16e1ce
@ -82,7 +82,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
|
||||
@ -90,7 +90,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
|
||||
|
Loading…
Reference in New Issue
Block a user