core: generalize the cgroup empty check on GC
Let's move the cgroup empty check for all unit types into the generic unit_check_gc() call, out of the per-unit-type _check_gc() type. This not only allows us to share some code, but also hooks up mount and socket units with this kind of check, for free, as it was missing there previously.
This commit is contained in:
@@ -460,18 +460,6 @@ static int scope_deserialize_item(Unit *u, const char *key, const char *value, F
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool scope_check_gc(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
/* Never clean up scopes that still have a process around,
|
||||
* even if the scope is formally dead. */
|
||||
|
||||
if (!u->cgroup_path)
|
||||
return false;
|
||||
|
||||
return cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path) <= 0;
|
||||
}
|
||||
|
||||
static void scope_notify_cgroup_empty_event(Unit *u) {
|
||||
Scope *s = SCOPE(u);
|
||||
assert(u);
|
||||
@@ -639,8 +627,6 @@ const UnitVTable scope_vtable = {
|
||||
.active_state = scope_active_state,
|
||||
.sub_state_to_string = scope_sub_state_to_string,
|
||||
|
||||
.check_gc = scope_check_gc,
|
||||
|
||||
.sigchld_event = scope_sigchld_event,
|
||||
|
||||
.reset_failed = scope_reset_failed,
|
||||
|
||||
Reference in New Issue
Block a user