From: Michael Tremer Date: Sat, 27 Sep 2025 15:27:55 +0000 (+0000) Subject: daemon: Cleanup the queue on exit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f78c251a9501158b4dba384ec56c7a7302a0808;p=telemetry.git daemon: Cleanup the queue on exit Signed-off-by: Michael Tremer --- 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)