goto ERROR;
// Create a new HTTP client
- r = pakfire_httpclient_create(&self->httpclient, self->ctx, self->loop);
+ r = pakfire_httpclient_create(&self->httpclient, self->ctx);
if (r < 0)
goto ERROR;
return sd_event_add_defer(self->loop, NULL, pakfire_httpclient_started, self);
}
-static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* self, sd_event* loop) {
+static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* self) {
int r;
- // Use the given loop
- if (loop) {
- self->loop = sd_event_ref(loop);
-
- // Otherwise create a new loop
- } else {
- r = pakfire_ctx_loop(self->ctx, &self->loop);
- if (r < 0) {
- ERROR(self->ctx, "Could not setup event loop: %s\n", strerror(-r));
+ // Fetch the context's loop
+ r = pakfire_ctx_loop(self->ctx, &self->loop);
+ if (r < 0) {
+ ERROR(self->ctx, "Could not setup event loop: %s\n", strerror(-r));
- return r;
- }
+ return r;
}
// Create a new timer
}
int pakfire_httpclient_create(struct pakfire_httpclient** client,
- struct pakfire_ctx* ctx, sd_event* loop) {
+ struct pakfire_ctx* ctx) {
struct pakfire_httpclient* self = NULL;
int r;
TAILQ_INIT(&self->xfers);
// Setup event loop
- r = pakfire_httpclient_setup_loop(self, loop);
+ r = pakfire_httpclient_setup_loop(self);
if (r)
goto ERROR;
#ifndef PAKFIRE_HTTPCLIENT_H
#define PAKFIRE_HTTPCLIENT_H
-// systemd
-#include <systemd/sd-event.h>
-
struct pakfire_httpclient;
#include <pakfire/ctx.h>
#include <pakfire/xfer.h>
-int pakfire_httpclient_create(struct pakfire_httpclient** client,
- struct pakfire_ctx* ctx, sd_event* loop);
+int pakfire_httpclient_create(struct pakfire_httpclient** client, struct pakfire_ctx* ctx);
struct pakfire_httpclient* pakfire_httpclient_ref(struct pakfire_httpclient* self);
struct pakfire_httpclient* pakfire_httpclient_unref(struct pakfire_httpclient* self);
int r;
// Initialize the HTTP client
- r = pakfire_httpclient_create(&httpclient, transaction->ctx, NULL);
+ r = pakfire_httpclient_create(&httpclient, transaction->ctx);
if (r) {
ERROR(transaction->ctx, "Could not initialize HTTP client: %m\n");
return 1;
int r = EXIT_FAILURE;
// Create a HTTP client
- ASSERT_SUCCESS(pakfire_httpclient_create(&client, t->ctx, NULL));
+ ASSERT_SUCCESS(pakfire_httpclient_create(&client, t->ctx));
// Everything passed
r = EXIT_SUCCESS;
// Create a HTTP client (if requested)
if (t->flags & TEST_WANTS_HTTPCLIENT) {
- r = pakfire_httpclient_create(&t->httpclient, t->ctx, NULL);
+ r = pakfire_httpclient_create(&t->httpclient, t->ctx);
if (r < 0) {
LOG("ERROR: Could not initialize the HTTP client: %s\n", strerror(-r));
goto ERROR;