]> git.ipfire.org Git - collecty.git/commitdiff
daemon: Cleanup the queue on exit
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 15:27:55 +0000 (15:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Sep 2025 15:27:55 +0000 (15:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/daemon.c

index d0a760d8bf137497053e0164210ded198b2148f0..741c8400c7a9053eea42e4a757cc166b517d927a 100644 (file)
@@ -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)