]> git.ipfire.org Git - pakfire.git/commitdiff
httpclient: Fix error handling when leaving the main loop early
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 13 Oct 2024 10:24:33 +0000 (10:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 13 Oct 2024 10:24:33 +0000 (10:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/httpclient.c

index 5be5671df267848c4710bb7ff1eb67ac025a40c4..d01a39a801d256f17bf90937a438c73234f44d46 100644 (file)
@@ -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;
 }