diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-07-12 18:00:44 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-07-12 18:30:46 +0530 |
commit | d1ae1c718a063e1bb9660f94b747d9206a8bba83 (patch) | |
tree | fec09651620b9d051d8ec9cf17d1396c81d6e75f | |
parent | 371b0058b9e25b383f3c8bc7aebb3f93360c1df2 (diff) |
queue: use single path for memory management
-rw-r--r-- | src/queue.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/queue.c b/src/queue.c index 049d62c..af96630 100644 --- a/src/queue.c +++ b/src/queue.c @@ -204,14 +204,20 @@ static int queue_push(struct queue *queue, struct job *job) void queue_thread_free(struct queue_thread *queue_thread) { - struct job *cur, *next; + struct job *j; int ret; if (queue_thread == NULL) return; - CIRCLEQ_FOREACH_FREE(cur, next, &queue_thread->queue->jobs, clist, - job_free); + while (!CIRCLEQ_EMPTY(&queue_thread->queue->jobs)) { + j = CIRCLEQ_FIRST(&queue_thread->queue->jobs); + ret = queue_dag_isolate(j, NULL, &queue_thread->queue->jobs, + queue_thread->queue->htab); + if (ret < 0) + return; + job_free(j); + } htab_free(queue_thread->queue->htab); ret = sem_destroy(&queue_thread->queue->sem); |