]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: don't gc unit in oom queue
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Jun 2023 09:11:28 +0000 (11:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jun 2023 09:15:40 +0000 (11:15 +0200)
This is a follow-up for 8db998981a4fefd0122bcf5f965726b63c9045c2, and
follows a similar logic: a pending OOM event really trumps everything:
we should not GC a unit while it is pending.

src/core/cgroup.c
src/core/unit.c

index 839b1676c88a29b5f5fde28a71b77cafa9a8ee6e..34643b242ceae61ee3fd21003a1f022580ad09a9 100644 (file)
@@ -3319,6 +3319,8 @@ static int on_cgroup_oom_event(sd_event_source *s, void *userdata) {
         }
 
         (void) unit_check_oom(u);
+        unit_add_to_gc_queue(u);
+
         return 0;
 }
 
index 7b6d50e0eaf554628091f25d3db91cfe4bce882c..80f398c309c430953e904843b2d34e72ea7c6570 100644 (file)
@@ -441,7 +441,10 @@ bool unit_may_gc(Unit *u) {
         if (u->perpetual)
                 return false;
 
-        if (u->in_cgroup_empty_queue)
+        /* if we saw a cgroup empty event for this unit, stay around until we processed it so that we remove
+         * the empty cgroup if possible. Similar, process any pending OOM events if they are already queued
+         * before we release the unit. */
+        if (u->in_cgroup_empty_queue || u->in_cgroup_oom_queue)
                 return false;
 
         if (sd_bus_track_count(u->bus_track) > 0)