util/queue: fix a data race detected by TSAN when finishing the queue
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 18 Nov 2021 15:58:42 +0000 (16:58 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 19 Nov 2021 08:02:23 +0000 (09:02 +0100)
commit04c90f292e1b6011f6c26eda957a61888d3a57da
tree9d6d8e0486e4ac2f61f107edc604c6e68f358afd
parentcee1dd92bd89374e27e1d431d42f0c469cc6e56e
util/queue: fix a data race detected by TSAN when finishing the queue

Thread sanitizer complains if it detects that the pthread_barrier
is destroyed when a thread might still blocked on the barrier.

Fix this by destroying the barrier only if pthread_barrier_wait
returns PTHREAD_BARRIER_SERIAL_THREAD which is the value for success.

In practice this shouldn't fix anything serious given that this code
is only called when the disk cache is destroyed.

Original patch from Timothy Arceri.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4342
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13861>
src/util/u_queue.c
src/util/u_thread.h