From: Michael Tremer Date: Fri, 27 Mar 2026 15:08:03 +0000 (+0000) Subject: daemon: Terminate the event loop if we fail to initialize X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff751cd4ae4a3d77d06fdb41de88a279e6d2e255;p=collecty.git daemon: Terminate the event loop if we fail to initialize Signed-off-by: Michael Tremer --- diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 21f11f7..2d116a5 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -99,21 +99,27 @@ static int td_daemon_init(sd_event_source* source, void* data) { // Initialize all sources r = td_sources_create(&self->sources, self->ctx, self, self->enabled_sources); if (r < 0) - return r; + goto ERROR; // Initialize all graphs r = td_graphs_create(&self->graphs, self->ctx, self); if (r < 0) - return r; + goto ERROR; #ifdef HAVE_SENSORS // Initialize sensors r = td_sensors_init(self->ctx); if (r < 0) - return r; + goto ERROR; #endif /* HAVE_SENSORS */ return 0; + +ERROR: + ERROR(self->ctx, "Failed to initialize: %s\n", strerror(-r)); + + // Terminating the event loop + return sd_event_exit(sd_event_source_get_event(source), r); } static int td_daemon_on_exit(sd_event_source* source, void* data) {