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>
This commit is contained in:
Marek Olšák 2019-10-23 21:01:38 -04:00
parent e096011def
commit c2efd2cbfb
1 changed files with 7 additions and 0 deletions

View File

@ -647,6 +647,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);