From fce94c5c563b8f6ede2b8f7f283d2d2faff4e062 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Jan 2025 10:09:32 +0900 Subject: [PATCH] core/unit: remove path to transient unit file from unit name maps on stop Fixes #35190. --- src/core/unit.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index 7685ab1996b..e6c5a45dcf2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -646,13 +646,11 @@ static void unit_clear_dependencies(Unit *u) { static void unit_remove_transient(Unit *u) { assert(u); + assert(u->manager); if (!u->transient) return; - if (u->fragment_path) - (void) unlink(u->fragment_path); - STRV_FOREACH(i, u->dropin_paths) { _cleanup_free_ char *p = NULL, *pp = NULL; @@ -669,6 +667,17 @@ static void unit_remove_transient(Unit *u) { (void) unlink(*i); (void) rmdir(p); } + + if (u->fragment_path) { + (void) unlink(u->fragment_path); + (void) unit_file_remove_from_name_map( + &u->manager->lookup_paths, + &u->manager->unit_cache_timestamp_hash, + &u->manager->unit_id_map, + &u->manager->unit_name_map, + &u->manager->unit_path_cache, + u->fragment_path); + } } static void unit_free_mounts_for(Unit *u) { -- 2.47.3