summaryrefslogtreecommitdiff
path: root/src/core/slice.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-19 20:40:05 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-19 21:06:53 +0100
commit598459cebac7cc93089769a992e7b03287f77e12 (patch)
treeab690b534e7578ce1d9421d5127224a43fd5fded /src/core/slice.c
parentae439c9f9b8a9cbb320d66290e3f9ad0e2f37378 (diff)
core: rework context initialization/destruction logic
Let's automatically initialize the kill, exec and cgroup contexts of the various unit types when the object is constructed, instead of invididually in type-specific code. Also, when PrivateDevices= is set, set DevicePolicy= to closed.
Diffstat (limited to 'src/core/slice.c')
-rw-r--r--src/core/slice.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/core/slice.c b/src/core/slice.c
index ae9a54ba69..057feefa0f 100644
--- a/src/core/slice.c
+++ b/src/core/slice.c
@@ -36,24 +36,6 @@ static const UnitActiveState state_translation_table[_SLICE_STATE_MAX] = {
[SLICE_ACTIVE] = UNIT_ACTIVE
};
-static void slice_init(Unit *u) {
- Slice *s = SLICE(u);
-
- assert(u);
- assert(u->load_state == UNIT_STUB);
-
- cgroup_context_init(&s->cgroup_context);
- unit_cgroup_context_init_defaults(u, &s->cgroup_context);
-}
-
-static void slice_done(Unit *u) {
- Slice *s = SLICE(u);
-
- assert(u);
-
- cgroup_context_done(&s->cgroup_context);
-}
-
static void slice_set_state(Slice *t, SliceState state) {
SliceState old_state;
assert(t);
@@ -153,6 +135,10 @@ static int slice_load(Unit *u) {
/* This is a new unit? Then let's add in some extras */
if (u->load_state == UNIT_LOADED) {
+ r = unit_patch_contexts(u);
+ if (r < 0)
+ return r;
+
r = slice_add_parent_slice(s);
if (r < 0)
return r;
@@ -287,9 +273,7 @@ const UnitVTable slice_vtable = {
.no_alias = true,
.no_instances = true,
- .init = slice_init,
.load = slice_load,
- .done = slice_done,
.coldplug = slice_coldplug,