From: Michael Tremer Date: Sat, 1 Feb 2025 14:00:54 +0000 (+0000) Subject: httpclient: Launch transfers as soon as they are enqueued when not in standalone... X-Git-Tag: 0.9.30~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1585e79cf506133597b3da771a1c0493fa067779;p=pakfire.git httpclient: Launch transfers as soon as they are enqueued when not in standalone mode Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/httpclient.c b/src/pakfire/httpclient.c index 19a257f1..fb9af9e6 100644 --- a/src/pakfire/httpclient.c +++ b/src/pakfire/httpclient.c @@ -55,7 +55,7 @@ struct pakfire_httpclient { // Flags enum { - PAKFIRE_HTTPCLIENT_OWN_LOOP = (1 << 0), + PAKFIRE_HTTPCLIENT_STANDALONE = (1 << 0), } flags; // Base URL @@ -303,7 +303,7 @@ static int pakfire_httpclient_check(struct pakfire_httpclient* self) { return r; // If we control the loop, terminate it if there are no more transfers left - if (pakfire_httpclient_has_flag(self, PAKFIRE_HTTPCLIENT_OWN_LOOP)) { + if (pakfire_httpclient_has_flag(self, PAKFIRE_HTTPCLIENT_STANDALONE)) { if (self->still_running <= 0) return sd_event_exit(self->loop, 0); } @@ -481,8 +481,8 @@ static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* self, sd_eve return r; } - // This is our very own loop - self->flags |= PAKFIRE_HTTPCLIENT_OWN_LOOP; + // We are no in standalone-mode + self->flags |= PAKFIRE_HTTPCLIENT_STANDALONE; } // Create a new timer @@ -694,7 +694,12 @@ int pakfire_httpclient_enqueue(struct pakfire_httpclient* self, struct pakfire_x // Keep a reference to the xfer TAILQ_INSERT_TAIL(&self->xfers, e, nodes); - return 0; + // We are done if we are running in standalone mode + if (pakfire_httpclient_has_flag(self, PAKFIRE_HTTPCLIENT_STANDALONE)) + return 0; + + // Otherwise we launch the transfer straight away + return pakfire_httpclient_launch_one(self, e); } int pakfire_httpclient_dequeue(struct pakfire_httpclient* self, struct pakfire_xfer* xfer) { @@ -723,6 +728,12 @@ int pakfire_httpclient_dequeue(struct pakfire_httpclient* self, struct pakfire_x int pakfire_httpclient_run(struct pakfire_httpclient* self, const char* title) { int r = 0; + // This can only be run in standalone-mode + if (!pakfire_httpclient_has_flag(self, PAKFIRE_HTTPCLIENT_STANDALONE)) { + ERROR(self->ctx, "Trying to launch HTTP client that is not in standalone-mode\n"); + return -ENOTSUP; + } + // Cannot run without any transfers if (TAILQ_EMPTY(&self->xfers)) { DEBUG(self->ctx, "Skipping running HTTP client without any transfers\n");