From 7041d26a271752272a3bddd8a3437084c29687d9 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Thu, 4 Jul 2024 08:06:28 +0530 Subject: queue/queue_pop: deadlock, unlock mutex on failure --- src/queue.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/queue.c b/src/queue.c index 35daf36..4592045 100644 --- a/src/queue.c +++ b/src/queue.c @@ -132,17 +132,20 @@ int queue_pop(struct queue *queue, struct job **job, struct htab *htab) if (evanix_opts.max_build) { ret = solver_greedy(&queue->jobs, &queue->resources, &j); if (ret < 0) - return ret; + goto out_mutex_unlock; } else { j = CIRCLEQ_FIRST(&queue->jobs); } ret = queue_dag_isolate(j, NULL, &queue->jobs, htab); if (ret < 0) - return ret; + goto out_mutex_unlock; + +out_mutex_unlock: pthread_mutex_unlock(&queue->mutex); - *job = j; - return 0; + if (ret >= 0) + *job = j; + return ret; } /* this merge functions are closely tied to the output characteristics of -- cgit v1.2.3