gallium/u_queue: fix a crash with atexit handlers
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 26 Feb 2017 00:44:06 +0000 (02:44 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 27 Feb 2017 13:49:15 +0000 (14:49 +0100)
commit993612193575f5f218af52c4ed7525e15083548e
tree0e03dcd3688b8a03c6878cd0fe1d1eeb83305f5a
parent43d833ae97daa73a2422b5696b587a7b46750e07
gallium/u_queue: fix a crash with atexit handlers

Commit 4aea8fe ("gallium/u_queue: fix random crashes when the app calls
exit()") added a atexit handler which calls
util_queue_killall_and_wait() for each queue to stop the threads.
However the app is also free to use atexit handlers to clean up things,
leading to util_queue_destroy() call which will also call
util_queue_killall_and_wait() for the same queue again, causing threads
being joined twice, and that is undefined. This happens with libglut,
for example. A simple fix is to just set num_threads to 0 as there are
no more valid threads after util_queue_killall_and_wait() returns.

Fixes: 4aea8fe "gallium/u_queue: fix random crashes when the app calls exit()"
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_queue.c