From: Michael Tremer Date: Sun, 13 Oct 2024 10:24:33 +0000 (+0000) Subject: httpclient: Fix error handling when leaving the main loop early X-Git-Tag: 0.9.30~1044 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d37a2bc4930f1d9737f747ad1a9bde10f62e98e;p=pakfire.git httpclient: Fix error handling when leaving the main loop early Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/httpclient.c b/src/libpakfire/httpclient.c index 5be5671df..d01a39a80 100644 --- a/src/libpakfire/httpclient.c +++ b/src/libpakfire/httpclient.c @@ -517,27 +517,23 @@ int pakfire_httpclient_run(struct pakfire_httpclient* client, const char* title) // Set the title r = pakfire_progress_set_title(client->progress, "%s", title); if (r) - return r; + goto ERROR; // Start the progress r = pakfire_progress_start(client->progress, client->total_downloadsize); if (r) - return r; + goto ERROR; // Run the event loop - do { - r = sd_event_run(client->loop, -1); - if (r < 0) { - CTX_ERROR(client->ctx, "Event loop failed: %s\n", strerror(-r)); - - return r; - } - } while (client->still_running > 0); + r = sd_event_loop(client->loop); + if (r < 0) { + CTX_ERROR(client->ctx, "Event loop failed: %s\n", strerror(-r)); + goto ERROR; + } +ERROR: // We are finished! - r = pakfire_progress_finish(client->progress); - if (r) - return r; + pakfire_progress_finish(client->progress); - return 0; + return r; }