if (!PyArg_ParseTuple(args, "O!", &CtxType, &ctx))
return -1;
- r = pakfire_buildservice_create(&self->service, ctx->ctx);
+ r = pakfire_buildservice_create(&self->service, ctx->ctx, NULL);
if (r) {
errno = -r;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, cli_config->ctx, NULL);
if (r)
goto ERROR;
return r;
}
-static int pakfire_buildservice_setup(struct pakfire_buildservice* service) {
+static int pakfire_buildservice_setup(struct pakfire_buildservice* service, sd_event* loop) {
struct pakfire_config* config = NULL;
const char* url = NULL;
const char* keytab = NULL;
goto ERROR;
// Setup the HTTP client
- r = pakfire_httpclient_create(&service->httpclient, service->ctx);
+ r = pakfire_httpclient_create(&service->httpclient, service->ctx, loop);
if (r)
goto ERROR;
}
PAKFIRE_EXPORT int pakfire_buildservice_create(
- struct pakfire_buildservice** service, struct pakfire_ctx* ctx) {
+ struct pakfire_buildservice** service, struct pakfire_ctx* ctx, sd_event* loop) {
struct pakfire_buildservice* s = NULL;
int r;
s->nrefs = 1;
// Setup everything
- r = pakfire_buildservice_setup(s);
+ r = pakfire_buildservice_setup(s, loop);
if (r)
goto ERROR;
return r;
}
+
+/*
+ Called before the daemon's
+*/
+int pakfire_buildservice_daemon(struct pakfire_buildservice* service) {
+ return 0;
+}
goto ERROR;
// Connect to the buildservice
- r = pakfire_buildservice_create(&d->service, d->ctx);
+ r = pakfire_buildservice_create(&d->service, d->ctx, d->loop);
if (r)
goto ERROR;
struct pakfire_ctx* ctx = pakfire_ctx(pakfire);
// Create a HTTP client
- r = pakfire_httpclient_create(&httpclient, ctx);
+ r = pakfire_httpclient_create(&httpclient, ctx, NULL);
if (r)
goto ERROR;
return r;
}
-static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* client) {
+static int pakfire_httpclient_setup_loop(struct pakfire_httpclient* client, sd_event* loop) {
int r;
- // Create a new event loop
- r = sd_event_new(&client->loop);
- if (r < 0) {
- CTX_ERROR(client->ctx, "Could not setup event loop: %s\n", strerror(-r));
+ // Use the given loop
+ if (loop) {
+ client->loop = sd_event_ref(loop);
- return r;
+ // Otherwise create a new loop
+ } else {
+ r = sd_event_new(&client->loop);
+ if (r < 0) {
+ CTX_ERROR(client->ctx, "Could not setup event loop: %s\n", strerror(-r));
+
+ return r;
+ }
}
// Create a new timer
free(client);
}
-int pakfire_httpclient_create(struct pakfire_httpclient** client, struct pakfire_ctx* ctx) {
+int pakfire_httpclient_create(struct pakfire_httpclient** client,
+ struct pakfire_ctx* ctx, sd_event* loop) {
struct pakfire_httpclient* c = NULL;
int r;
c->max_parallel = DEFAULT_MAX_PARALLEL;
// Setup event loop
- r = pakfire_httpclient_setup_loop(c);
+ r = pakfire_httpclient_setup_loop(c, loop);
if (r)
goto ERROR;
#include <json.h>
+#include <systemd/sd-event.h>
+
#include <pakfire/ctx.h>
-int pakfire_buildservice_create(struct pakfire_buildservice** service, struct pakfire_ctx* ctx);
+int pakfire_buildservice_create(struct pakfire_buildservice** service,
+ struct pakfire_ctx* ctx, sd_event* loop);
struct pakfire_buildservice* pakfire_buildservice_ref(struct pakfire_buildservice* service);
struct pakfire_buildservice* pakfire_buildservice_unref(struct pakfire_buildservice* service);
int pakfire_buildservice_job_finished(struct pakfire_buildservice* service,
const char* uuid, int success, const char* logfile, const char** packages);
+// Daemon
+
+int pakfire_buildservice_daemon(struct pakfire_buildservice* service);
+
#endif /* PAKFIRE_BUILDSERVICE_H */
#include <curl/curl.h>
+#include <systemd/sd-event.h>
+
struct pakfire_httpclient;
#include <pakfire/ctx.h>
#include <pakfire/xfer.h>
-int pakfire_httpclient_create(struct pakfire_httpclient** downloader, struct pakfire_ctx* ctx);
+int pakfire_httpclient_create(struct pakfire_httpclient** downloader,
+ struct pakfire_ctx* ctx, sd_event* loop);
struct pakfire_httpclient* pakfire_httpclient_ref(struct pakfire_httpclient* downloader);
struct pakfire_httpclient* pakfire_httpclient_unref(struct pakfire_httpclient* downloader);
return r;
// Create a HTTP client
- r = pakfire_httpclient_create(&httpclient, repo->ctx);
+ r = pakfire_httpclient_create(&httpclient, repo->ctx, NULL);
if (r)
goto ERROR;
}
// Create a new HTTP client
- r = pakfire_httpclient_create(&httpclient, repo->ctx);
+ r = pakfire_httpclient_create(&httpclient, repo->ctx, NULL);
if (r)
goto ERROR;
}
// Create a HTTP client
- r = pakfire_httpclient_create(&httpclient, repo->ctx);
+ r = pakfire_httpclient_create(&httpclient, repo->ctx, NULL);
if (r)
goto ERROR;
}
// Create the HTTP client
- r = pakfire_httpclient_create(&httpclient, repo->ctx);
+ r = pakfire_httpclient_create(&httpclient, repo->ctx, NULL);
if (r)
goto ERROR;
int r;
// Initialize the HTTP client
- r = pakfire_httpclient_create(&httpclient, transaction->ctx);
+ r = pakfire_httpclient_create(&httpclient, transaction->ctx, NULL);
if (r) {
ERROR(transaction->pakfire, "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));
+ ASSERT_SUCCESS(pakfire_httpclient_create(&client, t->ctx, NULL));
// 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);
+ r = pakfire_httpclient_create(&t->httpclient, t->ctx, NULL);
if (r) {
LOG("ERROR: Could not initialize the HTTP client: %s\n", strerror(-r));
goto ERROR;