From: Michael Tremer Date: Tue, 24 Jun 2025 15:46:03 +0000 (+0000) Subject: client: Hold a reference to the event loop X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d997ec781547e36ceb468a8fa3e46f4ff8f3756;p=pakfire.git client: Hold a reference to the event loop Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/client.c b/src/pakfire/client.c index fa65af70..77f4ccf0 100644 --- a/src/pakfire/client.c +++ b/src/pakfire/client.c @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -41,6 +43,9 @@ struct pakfire_client { struct pakfire_ctx* ctx; int nrefs; + // Event Loop + sd_event* loop; + // HTTP Client struct pakfire_httpclient* httpclient; @@ -251,6 +256,10 @@ static int pakfire_client_xfer_auth(struct pakfire_client* self, struct pakfire_ } static void pakfire_client_free(struct pakfire_client* self) { + // Event Loop + if (self->loop) + sd_event_unref(self->loop); + if (self->httpclient) pakfire_httpclient_unref(self->httpclient); if (self->ctx) @@ -275,8 +284,11 @@ int pakfire_client_create(struct pakfire_client** client, // Initialize the reference counter self->nrefs = 1; + // Store a reference to the event loop + self->loop = sd_event_ref(loop); + // Create a new HTTP client - r = pakfire_httpclient_create(&self->httpclient, self->ctx, loop); + r = pakfire_httpclient_create(&self->httpclient, self->ctx, self->loop); if (r < 0) goto ERROR;