From: Michael Tremer Date: Tue, 24 Jun 2025 15:56:19 +0000 (+0000) Subject: client: Move the authentication timer from the daemon X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1ced7a0bc28c6b2d53cee2bbf2944e32a84fbbb2;p=pakfire.git client: Move the authentication timer from the daemon Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/client.c b/src/pakfire/client.c index 7450957f..289ef878 100644 --- a/src/pakfire/client.c +++ b/src/pakfire/client.c @@ -55,6 +55,12 @@ struct pakfire_client { // Configuration char keytab[PATH_MAX]; + // Authentication + struct pakfire_client_auth { + // Timer + sd_event_source* timer; + } auth; + // Tokens char access_token[1024]; time_t access_token_expires_at; @@ -230,6 +236,14 @@ ERROR: return r; } +static int pakfire_client_auth_timer(sd_event_source* event, uint64_t usec, void* data) { + struct pakfire_client* self = data; + + DEBUG(self->ctx, "Authentication timer fired\n"); + + return 0; +} + static int pakfire_client_xfer_auth(struct pakfire_client* self, struct pakfire_xfer* xfer) { int r; @@ -256,6 +270,9 @@ static int pakfire_client_xfer_auth(struct pakfire_client* self, struct pakfire_ } static void pakfire_client_free(struct pakfire_client* self) { + if (self->auth.timer) + sd_event_source_unref(self->auth.timer); + // Event Loop if (self->loop) sd_event_unref(self->loop); @@ -297,6 +314,21 @@ int pakfire_client_create(struct pakfire_client** client, if (r < 0) goto ERROR; + // Setup the authentication timer + r = sd_event_add_time_relative(self->loop, &self->auth.timer, + CLOCK_MONOTONIC, 0, 0, pakfire_client_auth_timer, self); + if (r < 0) { + ERROR(self->ctx, "Could not register the auth timer: %s\n", strerror(-r)); + goto ERROR; + } + + // Disable the authentication timer + r = sd_event_source_set_enabled(self->auth.timer, SD_EVENT_OFF); + if (r < 0) { + ERROR(self->ctx, "Could not activate the auth timer: %s\n", strerror(-r)); + goto ERROR; + } + DEBUG(self->ctx, "Pakfire Build Service initialized for %s\n", pakfire_client_get_url(self));