[systemd-commits] 2 commits - src/core

Lennart Poettering lennart at kemper.freedesktop.org
Mon Dec 8 17:31:50 PST 2014


 src/core/cgroup.c  |    7 ++++---
 src/core/cgroup.h  |    2 +-
 src/core/service.c |    2 +-
 src/core/unit.c    |    2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

New commits:
commit b1491eba40715438b0ac874f2be79d5622b971e1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 9 02:31:42 2014 +0100

    core: rename unit_destroy_cgroup() to unit_destroy_cgroup_if_empty() since it's not quite as destructive as it sounds nowadays

diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index af04835..6815ca9 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -782,7 +782,7 @@ int unit_realize_cgroup(Unit *u) {
         return unit_realize_cgroup_now(u, manager_state(u->manager));
 }
 
-void unit_destroy_cgroup(Unit *u) {
+void unit_destroy_cgroup_if_empty(Unit *u) {
         int r;
 
         assert(u);
@@ -802,7 +802,6 @@ void unit_destroy_cgroup(Unit *u) {
         u->cgroup_path = NULL;
         u->cgroup_realized = false;
         u->cgroup_realized_mask = 0;
-
 }
 
 pid_t unit_search_main_pid(Unit *u) {
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 3c43885..16d6613 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -109,7 +109,7 @@ CGroupControllerMask unit_get_target_mask(Unit *u);
 
 void unit_update_cgroup_members_masks(Unit *u);
 int unit_realize_cgroup(Unit *u);
-void unit_destroy_cgroup(Unit *u);
+void unit_destroy_cgroup_if_empty(Unit *u);
 
 int manager_setup_cgroup(Manager *m);
 void manager_shutdown_cgroup(Manager *m, bool delete);
diff --git a/src/core/service.c b/src/core/service.c
index 53a2935..bfbe959 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -703,7 +703,7 @@ static void service_set_state(Service *s, ServiceState state) {
         /* For the inactive states unit_notify() will trim the cgroup,
          * but for exit we have to do that ourselves... */
         if (state == SERVICE_EXITED && UNIT(s)->manager->n_reloading <= 0)
-                unit_destroy_cgroup(UNIT(s));
+                unit_destroy_cgroup_if_empty(UNIT(s));
 
         /* For remain_after_exit services, let's see if we can "release" the
          * hold on the console, since unit_notify() only does that in case of
diff --git a/src/core/unit.c b/src/core/unit.c
index 7daf170..43280ec 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1783,7 +1783,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
 
         /* Make sure the cgroup is always removed when we become inactive */
         if (UNIT_IS_INACTIVE_OR_FAILED(ns))
-                unit_destroy_cgroup(u);
+                unit_destroy_cgroup_if_empty(u);
 
         /* Note that this doesn't apply to RemainAfterExit services exiting
          * successfully, since there's no change of state in that case. Which is

commit dab5bf859900c0abdbf78c584e4aed42a19768cd
Author: Ross Lagerwall <rosslagerwall at gmail.com>
Date:   Sat Nov 29 15:27:14 2014 +0000

    cgroup: Handle error when destroying cgroup
    
    If a cgroup fails to be destroyed (most likely because there are still
    processes running as part of a service after the main pid exits), don't
    free and remove the cgroup unit from the manager.  This fixes a
    regression introduced by the cgroup rework in v205 where systemd would
    forget about processes still running after the unit becomes inactive.
    (This can happen when the main pid exits and KillMode=process or none).

diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 70fc925..af04835 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -791,8 +791,10 @@ void unit_destroy_cgroup(Unit *u) {
                 return;
 
         r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !unit_has_name(u, SPECIAL_ROOT_SLICE));
-        if (r < 0)
+        if (r < 0) {
                 log_debug_errno(r, "Failed to destroy cgroup %s: %m", u->cgroup_path);
+                return;
+        }
 
         hashmap_remove(u->manager->cgroup_unit, u->cgroup_path);
 



More information about the systemd-commits mailing list