summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgroup.c14
-rw-r--r--src/cgroup.h3
-rw-r--r--src/unit.c3
3 files changed, 20 insertions, 0 deletions
diff --git a/src/cgroup.c b/src/cgroup.c
index 27130a9c39..244a602024 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -101,6 +101,20 @@ void cgroup_bonding_free_list(CGroupBonding *first) {
cgroup_bonding_free(b);
}
+void cgroup_bonding_trim(CGroupBonding *b, bool delete_root) {
+ assert(b);
+
+ if (b->realized && b->only_us && b->clean_up)
+ cg_trim(b->controller, b->path, delete_root);
+}
+
+void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root) {
+ CGroupBonding *b;
+
+ LIST_FOREACH(by_unit, b, first)
+ cgroup_bonding_trim(b, delete_root);
+}
+
int cgroup_bonding_install(CGroupBonding *b, pid_t pid) {
int r;
diff --git a/src/cgroup.h b/src/cgroup.h
index 11d2aba8cf..05c858c425 100644
--- a/src/cgroup.h
+++ b/src/cgroup.h
@@ -61,6 +61,9 @@ int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid);
int cgroup_bonding_kill(CGroupBonding *b, int sig);
int cgroup_bonding_kill_list(CGroupBonding *first, int sig);
+void cgroup_bonding_trim(CGroupBonding *first, bool delete_root);
+void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root);
+
int cgroup_bonding_is_empty(CGroupBonding *b);
int cgroup_bonding_is_empty_list(CGroupBonding *first);
diff --git a/src/unit.c b/src/unit.c
index c287310a48..18faae22e4 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -973,6 +973,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
if (ns != os && ns == UNIT_MAINTENANCE)
log_notice("Unit %s entered maintenance state.", u->meta.id);
+ if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns))
+ cgroup_bonding_trim_list(u->meta.cgroup_bondings, true);
+
timer_unit_notify(u, ns);
path_unit_notify(u, ns);