summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-04 08:06:28 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-04 08:09:16 +0530
commit7041d26a271752272a3bddd8a3437084c29687d9 (patch)
treee8577c52b60df71ba604fa51d676e2c006fe79f0 /src
parentf804e6bf5860a419cb20b7372d3f6d56461532dd (diff)
queue/queue_pop: deadlock, unlock mutex on failure
Diffstat (limited to 'src')
-rw-r--r--src/queue.c11
1 files changed, 7 insertions, 4 deletions
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