#include <pakfire/util.h>
#include <pakfire/worker.h>
+#define MAX_WORKERS 64
+
struct pakfire_daemon {
struct pakfire_ctx* ctx;
int nrefs;
// Connection Timer and Holdoff Time
sd_event_source* connect_timer;
unsigned int reconnect_holdoff;
+
+ // Workers
+ struct pakfire_worker* workers[MAX_WORKERS];
+ unsigned int running_workers;
};
static int pakfire_daemon_terminate(sd_event_source* source,
if (r) {
CTX_ERROR(daemon->ctx, "Could not create a new worker: %s\n", strerror(-r));
- return r;
+ goto ERROR;
+ }
+
+ // Store the new worker
+ for (unsigned int i = 0; i < MAX_WORKERS; i++) {
+ if (!daemon->workers[i]) {
+ daemon->workers[i] = pakfire_worker_ref(worker);
+ break;
+ }
}
+ // Increment the number of running workers
+ daemon->running_workers++;
+
// XXX TODO We need to do something with the new worker
- return 0;
+ERROR:
+ if (worker)
+ pakfire_worker_unref(worker);
+
+ return r;
}
static int pakfire_daemon_recv(struct pakfire_xfer* xfer,