util/queue: handle thread cration failure in util_queue_adjust_num_threads

If a thread cannot be created, make sure the num_threads field is
updated to reflect the actual number of threads.

Signed-off-by: Greg Depoire--Ferrer <greg.depoire@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15071>
This commit is contained in:
Greg Depoire--Ferrer 2022-02-18 01:11:17 +01:00 committed by Marge Bot
parent d3bef6ba73
commit 969dfabc77

View file

@ -392,8 +392,10 @@ util_queue_adjust_num_threads(struct util_queue *queue, unsigned num_threads)
*/ */
queue->num_threads = num_threads; queue->num_threads = num_threads;
for (unsigned i = old_num_threads; i < num_threads; i++) { for (unsigned i = old_num_threads; i < num_threads; i++) {
if (!util_queue_create_thread(queue, i)) if (!util_queue_create_thread(queue, i)) {
queue->num_threads = i;
break; break;
}
} }
simple_mtx_unlock(&queue->finish_lock); simple_mtx_unlock(&queue->finish_lock);
} }