util/u_queue: skip util_queue_finish if num_threads is 0

This fixes a deadlock in pthread_barrier_destroy.

Cc: 19.1 19.2 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit c2efd2cbfb)
This commit is contained in:
Marek Olšák 2019-10-23 21:01:38 -04:00 committed by Dylan Baker
parent e2b416e8ae
commit 340849f311

View file

@ -637,6 +637,13 @@ util_queue_finish(struct util_queue *queue)
* wait for it exclusively.
*/
mtx_lock(&queue->finish_lock);
/* The number of threads can be changed to 0, e.g. by the atexit handler. */
if (!queue->num_threads) {
mtx_unlock(&queue->finish_lock);
return;
}
fences = malloc(queue->num_threads * sizeof(*fences));
util_barrier_init(&barrier, queue->num_threads);