// Events
struct {
sd_event_source* flush;
+ sd_event_source* exit;
} events;
// Queue
return collecty_queue_flush(self);
}
+static int collecty_queue_exit(sd_event_source* source, void* data) {
+ collecty_queue* self = data;
+
+ // Flush the queue
+ return collecty_queue_flush(self);
+}
+
static void collecty_queue_free_object(struct collecty_queue_object* o) {
if (o->module)
collecty_module_unref(o->module);
collecty_queue_free_object(o);
}
+ if (self->events.exit)
+ sd_event_source_unref(self->events.exit);
if (self->events.flush)
sd_event_source_unref(self->events.flush);
if (self->ctx)
goto ERROR;
}
+ // Create an event that is called when the loop exits
+ r = sd_event_add_exit(self->loop, &self->events.exit, collecty_queue_exit, self);
+ if (r < 0) {
+ ERROR(self->ctx, "Failed to setup exit handler: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
// Return the pointer
*queue = self;
return 0;