]> git.ipfire.org Git - pakfire.git/commitdiff
daemon: Create a cgroup for the daemon
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Dec 2024 16:39:51 +0000 (16:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Dec 2024 16:39:51 +0000 (16:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/daemon.c

index 5488b9c92829f7780f76bfbbfd40f59faf010daa..f7f2b099e008adfbb615665ef2ae3c1d591d4952 100644 (file)
@@ -27,6 +27,7 @@
 #include <systemd/sd-event.h>
 
 #include <pakfire/arch.h>
+#include <pakfire/cgroup.h>
 #include <pakfire/ctx.h>
 #include <pakfire/daemon.h>
 #include <pakfire/httpclient.h>
@@ -59,6 +60,9 @@ struct pakfire_daemon {
        // Timer for submitting stats
        sd_event_source* stats_timer;
 
+       // cgroup
+       struct pakfire_cgroup* cgroup;
+
        // Jobs
        struct pakfire_job* jobs[MAX_JOBS];
        unsigned int running_jobs;
@@ -680,6 +684,8 @@ static void pakfire_daemon_free(struct pakfire_daemon* daemon) {
                sd_event_source_unref(daemon->stats_timer);
        if (daemon->client)
                pakfire_httpclient_unref(daemon->client);
+       if (daemon->cgroup)
+               pakfire_cgroup_unref(daemon->cgroup);
        if (daemon->control)
                pakfire_xfer_unref(daemon->control);
        if (daemon->loop)
@@ -714,6 +720,11 @@ int pakfire_daemon_create(struct pakfire_daemon** daemon, struct pakfire_ctx* ct
        if (r)
                goto ERROR;
 
+       // Create the cgroup
+       r = pakfire_cgroup_create(&d->cgroup, d->ctx, "pakfire-daemon", 0);
+       if (r < 0)
+               goto ERROR;
+
        // Create the HTTP client
        r = pakfire_httpclient_create(&d->client, d->ctx, d->loop);
        if (r < 0)