diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-08-22 16:49:49 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-08-22 16:50:52 +0200 |
commit | 95939aed212c4e01059ce237e0426ede2aaffd86 (patch) | |
tree | db1eab7ddc42146fa027b528e4d014e919874e9c | |
parent | NEWS: update contributors list (diff) | |
download | systemd-95939aed212c4e01059ce237e0426ede2aaffd86.tar.xz systemd-95939aed212c4e01059ce237e0426ede2aaffd86.zip |
core: introduce unit_destroy_runtime_directory()
Currently `unit_will_restart()` can return true only when the unit is
service. Hence, should not change anything.
-rw-r--r-- | src/core/service.c | 6 | ||||
-rw-r--r-- | src/core/unit.c | 6 | ||||
-rw-r--r-- | src/core/unit.h | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/core/service.c b/src/core/service.c index d8cfb40145..d264b9a281 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1789,10 +1789,8 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) /* We want fresh tmpdirs in case service is started again immediately */ s->exec_runtime = exec_runtime_unref(s->exec_runtime, true); - if (s->exec_context.runtime_directory_preserve_mode == EXEC_PRESERVE_NO || - (s->exec_context.runtime_directory_preserve_mode == EXEC_PRESERVE_RESTART && !service_will_restart(UNIT(s)))) - /* Also, remove the runtime directory */ - exec_context_destroy_runtime_directory(&s->exec_context, UNIT(s)->manager->prefix[EXEC_DIRECTORY_RUNTIME]); + /* Also, remove the runtime directory */ + unit_destroy_runtime_directory(UNIT(s), &s->exec_context); /* Get rid of the IPC bits of the user */ unit_unref_uid_gid(UNIT(s), true); diff --git a/src/core/unit.c b/src/core/unit.c index 31ed473f91..ff979ffdd6 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5880,6 +5880,12 @@ int unit_test_trigger_loaded(Unit *u) { return 0; } +void unit_destroy_runtime_directory(Unit *u, const ExecContext *context) { + if (context->runtime_directory_preserve_mode == EXEC_PRESERVE_NO || + (context->runtime_directory_preserve_mode == EXEC_PRESERVE_RESTART && !unit_will_restart(u))) + exec_context_destroy_runtime_directory(context, u->manager->prefix[EXEC_DIRECTORY_RUNTIME]); +} + int unit_clean(Unit *u, ExecCleanMask mask) { UnitActiveState state; diff --git a/src/core/unit.h b/src/core/unit.h index 4732d72202..00436dc664 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -860,6 +860,7 @@ int unit_failure_action_exit_status(Unit *u); int unit_test_trigger_loaded(Unit *u); +void unit_destroy_runtime_directory(Unit *u, const ExecContext *context); int unit_clean(Unit *u, ExecCleanMask mask); int unit_can_clean(Unit *u, ExecCleanMask *ret_mask); |