diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-03-19 20:40:05 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-19 21:06:53 +0100 |
commit | 598459cebac7cc93089769a992e7b03287f77e12 (patch) | |
tree | ab690b534e7578ce1d9421d5127224a43fd5fded /src/core/service.c | |
parent | ae439c9f9b8a9cbb320d66290e3f9ad0e2f37378 (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/service.c')
-rw-r--r-- | src/core/service.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/core/service.c b/src/core/service.c index fe7ddd1841..78a2e06fff 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -143,12 +143,6 @@ static void service_init(Unit *u) { s->socket_fd = -1; s->guess_main_pid = true; - exec_context_init(&s->exec_context); - kill_context_init(&s->kill_context); - cgroup_context_init(&s->cgroup_context); - - unit_cgroup_context_init_defaults(u, &s->cgroup_context); - RATELIMIT_INIT(s->start_limit, u->manager->default_start_limit_interval, u->manager->default_start_limit_burst); s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID; @@ -301,8 +295,6 @@ static void service_done(Unit *u) { free(s->status_text); s->status_text = NULL; - cgroup_context_done(&s->cgroup_context); - exec_context_done(&s->exec_context); s->exec_runtime = exec_runtime_unref(s->exec_runtime); exec_command_free_array(s->exec_command, _SERVICE_EXEC_COMMAND_MAX); s->control_command = NULL; @@ -1202,11 +1194,15 @@ static int service_load(Unit *u) { service_fix_output(s); + r = unit_patch_contexts(u); + if (r < 0) + return r; + r = unit_add_exec_dependencies(u, &s->exec_context); if (r < 0) return r; - r = unit_add_default_slice(u); + r = unit_add_default_slice(u, &s->cgroup_context); if (r < 0) return r; @@ -1216,27 +1212,23 @@ static int service_load(Unit *u) { return r; #endif - if (s->bus_name) { - r = unit_watch_bus_name(u, s->bus_name); - if (r < 0) - return r; - } - if (s->type == SERVICE_NOTIFY && s->notify_access == NOTIFY_NONE) s->notify_access = NOTIFY_MAIN; if (s->watchdog_usec > 0 && s->notify_access == NOTIFY_NONE) s->notify_access = NOTIFY_MAIN; - if (UNIT(s)->default_dependencies) { - r = service_add_default_dependencies(s); + if (s->bus_name) { + r = unit_watch_bus_name(u, s->bus_name); if (r < 0) return r; } - r = unit_exec_context_patch_defaults(u, &s->exec_context); - if (r < 0) - return r; + if (u->default_dependencies) { + r = service_add_default_dependencies(s); + if (r < 0) + return r; + } } return service_verify(s); |