]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit: remove path to transient unit file from unit name maps on stop
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jan 2025 01:09:32 +0000 (10:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jan 2025 19:58:24 +0000 (04:58 +0900)
Fixes #35190.

src/core/unit.c

index 7685ab1996b05429947e2587dce54a29739cbb50..e6c5a45dcf2ae7aa072607afd7440467a52014be 100644 (file)
@@ -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) {