// Flags
enum {
- PAKFIRE_HTTPCLIENT_OWN_LOOP = (1 << 0),
+ PAKFIRE_HTTPCLIENT_STANDALONE = (1 << 0),
} flags;
// Base URL
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);
}
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
// 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) {
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");