From 969dfabc7796fab9f43b5e320c8d3506b4e29ba4 Mon Sep 17 00:00:00 2001 From: Greg Depoire--Ferrer Date: Fri, 18 Feb 2022 01:11:17 +0100 Subject: [PATCH] util/queue: handle thread cration failure in util_queue_adjust_num_threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Part-of: --- src/util/u_queue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/u_queue.c b/src/util/u_queue.c index 6681f0950d8..d7da1af6060 100644 --- a/src/util/u_queue.c +++ b/src/util/u_queue.c @@ -392,8 +392,10 @@ util_queue_adjust_num_threads(struct util_queue *queue, unsigned num_threads) */ queue->num_threads = num_threads; 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; + } } simple_mtx_unlock(&queue->finish_lock); }