]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: after creating transient drop-ins, put file in path cache
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 21 Aug 2019 07:14:52 +0000 (09:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Aug 2019 13:35:21 +0000 (15:35 +0200)
The alternative would be to recreate the cache, but dropins can be created very
often for transient settings, so updating the cache seems like a much faster
option.

Fixes #13287.

src/core/unit.c

index 9dc75223a72f025bec318462a8e287575081e589..f46858691b4e313d4ef4aa51d17ce8490b2f961a 100644 (file)
@@ -4583,6 +4583,15 @@ int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const ch
                 return r;
 
         (void) mkdir_p_label(p, 0755);
+
+        /* Make sure the drop-in dir is registered in our path cache. This way we don't need to stupidly
+         * recreate the cache after every drop-in we write. */
+        if (u->manager->unit_path_cache) {
+                r = set_put_strdup(u->manager->unit_path_cache, p);
+                if (r < 0)
+                        return r;
+        }
+
         r = write_string_file_atomic_label(q, wrapped);
         if (r < 0)
                 return r;