]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: optimize unit_write_drop_in a bit
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Apr 2016 16:13:02 +0000 (18:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 12 Apr 2016 11:43:33 +0000 (13:43 +0200)
There's no point in first determining the drop-in file name path, then
forgetting it again, and then determining it again. Instead, just generated it
once, and then write to ti directly.

src/core/unit.c

index fb4f3ddff687c86147fdd088608c61620de090cb..08f3288776ca83ca20eeb29dd39033bbd041bf21 100644 (file)
@@ -3379,17 +3379,19 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
         prefixed = strjoina("# This is a drop-in unit file extension, created via \"systemctl set-property\" or an equivalent operation. Do not edit.\n",
                             data);
 
-        r = write_drop_in(dir, u->id, 50, name, prefixed);
+        r = drop_in_file(dir, u->id, 50, name, &p, &q);
         if (r < 0)
                 return r;
 
-        r = drop_in_file(dir, u->id, 50, name, &p, &q);
+        (void) mkdir_p(p, 0755);
+        r = write_string_file_atomic_label(q, prefixed);
         if (r < 0)
                 return r;
 
-        r = strv_extend(&u->dropin_paths, q);
+        r = strv_push(&u->dropin_paths, q);
         if (r < 0)
                 return r;
+        q = NULL;
 
         strv_uniq(u->dropin_paths);