// Event Loop
sd_event* loop;
- int is_running;
int still_running;
// Timer
return r;
}
-static int pakfire_httpclient_exited(sd_event_source* event, void* data);
-
-static int pakfire_httpclient_started(sd_event_source* event, void* data) {
- struct pakfire_httpclient* self = data;
-
- DEBUG(self->ctx, "Event loop started\n");
-
- // Mark as running
- self->is_running = 1;
-
- // Register an event that get's called once we exit
- return sd_event_add_exit(self->loop, NULL, pakfire_httpclient_exited, self);
-}
-
-static int pakfire_httpclient_exited(sd_event_source* event, void* data) {
- struct pakfire_httpclient* self = data;
-
- DEBUG(self->ctx, "Event loop exited\n");
-
- // Mark as not running
- self->is_running = 0;
-
- // Register an event so that we catch when the loop is being restarted
- return sd_event_add_defer(self->loop, NULL, pakfire_httpclient_started, self);
-}
-
static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* self) {
int r;
return r;
}
- // Have something fire when the loop has started
- r = sd_event_add_defer(self->loop, NULL, pakfire_httpclient_started, self);
- if (r < 0)
- return r;
-
return 0;
}
TAILQ_INSERT_TAIL(&self->xfers, e, nodes);
// Launch the transfer straight away if we are running already
- if (self->is_running)
+ if (pakfire_ctx_loop_is_running(self->ctx))
return pakfire_httpclient_launch_one(self, e);
return 0;