From 95939aed212c4e01059ce237e0426ede2aaffd86 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 22 Aug 2019 23:49:49 +0900 Subject: [PATCH] core: introduce unit_destroy_runtime_directory() Currently `unit_will_restart()` can return true only when the unit is service. Hence, should not change anything. --- src/core/service.c | 6 ++---- src/core/unit.c | 6 ++++++ 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 d8cfb401455..d264b9a2811 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 31ed473f910..ff979ffdd60 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 4732d722029..00436dc6641 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); -- 2.39.2