core: Don't GC unit if it is in cgroup_empty_queue

The gc_unit_queue is dispatched before the cgroup_empty_queue.  Because
of this, when we enter in on_cgroup_empty_event, the unit in
cgroup_empty_queue may already have been freed and we don't clean up the
corresponding cgroup. With this change, we prevent the unit from being
garbage collected if it is in the cgroup_empty_queue.
This commit is contained in:
Richard Phibel
2023-05-29 13:26:15 +02:00
parent e30b4c1357
commit 8db998981a
2 changed files with 52 additions and 0 deletions
+3
View File
@@ -441,6 +441,9 @@ bool unit_may_gc(Unit *u) {
if (u->perpetual)
return false;
if (u->in_cgroup_empty_queue)
return false;
if (sd_bus_track_count(u->bus_track) > 0)
return false;