]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: thread: use pthread_self() not ha_pthread[tid] in set_affinity
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Mar 2025 14:54:36 +0000 (15:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Mar 2025 14:59:23 +0000 (15:59 +0100)
commit12383fd9f5b3614dbffec6260b82659c3c5fd0df
tree87d48886086d04916ec6407223119921c3b66567
parente94230521492f3a5c3a7afec77d7a1a499832795
BUG/MEDIUM: thread: use pthread_self() not ha_pthread[tid] in set_affinity

A bug was uncovered by the work on NUMA. It only triggers in the CI
with libmusl due to a race condition. What happens is that the call
to set_thread_cpu_affinity() is done very early in the polling loop,
and that it relies on ha_pthread[tid] instead of pthread_self(). The
problem is that ha_pthread[tid] is only set by the return from
pthread_create(), which might happen later depending on the number of
CPUs available to run the starting thread.

Let's just use pthread_self() here. ha_pthread[] is only used to send
signals between threads, there's no point in using it here.

This can be backported to 2.6.
src/thread.c