aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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