diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-07-11 18:47:20 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-07-11 18:49:53 +0200 |
commit | d7bd3de0654669e65b9642c248c5fa6d1d9a9f61 (patch) | |
tree | fdc089ab250d033b3636f19e6dfb14d83e2d5d8e /src/core | |
parent | 8a84192905a9845fda31b65cc433127f9c2f95ae (diff) |
cgroup: simplify how instantiated units are mapped to cgroups
Previously for an instantiated unit foo@bar.service we created a cgroup
foo@.service/foo@bar.service, in order to place all instances of the
same template inside the same subtree. As we now implicitly add all
instantiated units into one per-template slice we don't need this
complexity anymore, and instance units can map directly to the cgroups
of their full name.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/unit.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index bfde08d68c..86452859bc 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1991,7 +1991,7 @@ char *unit_dbus_path(Unit *u) { } char *unit_default_cgroup_path(Unit *u) { - _cleanup_free_ char *escaped_instance = NULL, *slice = NULL; + _cleanup_free_ char *escaped = NULL, *slice = NULL; int r; assert(u); @@ -2005,28 +2005,14 @@ char *unit_default_cgroup_path(Unit *u) { return NULL; } - escaped_instance = cg_escape(u->id); - if (!escaped_instance) + escaped = cg_escape(u->id); + if (!escaped) return NULL; - if (u->instance) { - _cleanup_free_ char *t = NULL, *escaped_template = NULL; - - t = unit_name_template(u->id); - if (!t) - return NULL; - - escaped_template = cg_escape(t); - if (!escaped_template) - return NULL; - - return strjoin(u->manager->cgroup_root, "/", - slice ? slice : "", slice ? "/" : "", - escaped_template, "/", escaped_instance, NULL); - } else - return strjoin(u->manager->cgroup_root, "/", - slice ? slice : "", slice ? "/" : "", - escaped_instance, NULL); + if (slice) + return strjoin(u->manager->cgroup_root, "/", slice, "/", escaped, NULL); + else + return strjoin(u->manager->cgroup_root, "/", escaped, NULL); } int unit_add_default_slice(Unit *u) { |