summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-04-08 18:13:02 +0200
committerLennart Poettering <lennart@poettering.net>2016-04-12 13:43:33 +0200
commit815b09d39b74a9ece31b7d7ef45f8f00784b8d8b (patch)
tree0265d12c2b50c86ff59c71d90d637421153cc3f8 /src
parente20b2a867ac5ac7ff6d43898fb83bc78f730909e (diff)
core: optimize unit_write_drop_in a bit
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/unit.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index fb4f3ddff6..08f3288776 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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);