From 5f78c251a9501158b4dba384ec56c7a7302a0808 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 27 Sep 2025 15:27:55 +0000 Subject: [PATCH] daemon: Cleanup the queue on exit Signed-off-by: Michael Tremer --- src/daemon/daemon.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index d0a760d..741c840 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -131,6 +131,7 @@ static void collecty_daemon_free_queue_object(struct collecty_queue_object* o) { free(o->object); if (o->value) free(o->value); + free(o); } static int collecty_daemon_setup_queue(collecty_daemon* self) { @@ -141,6 +142,21 @@ static int collecty_daemon_setup_queue(collecty_daemon* self) { } static void collecty_daemon_free(collecty_daemon* self) { + struct collecty_queue_object* o = NULL; + + // Cleanup the queue + for (;;) { + o = STAILQ_FIRST(&self->queue); + if (!o) + break; + + // Remove the object from the queue + STAILQ_REMOVE_HEAD(&self->queue, nodes); + + // Free the object + collecty_daemon_free_queue_object(o); + } + if (self->events.modules_init) sd_event_source_unref(self->events.modules_init); if (self->events.sigterm) -- 2.47.3