9ecd5b8
From 94b9640cc14a71c6df32da4e218c0b3cfb9b8795 Mon Sep 17 00:00:00 2001
9ecd5b8
From: WaLyong Cho <walyong.cho@samsung.com>
9ecd5b8
Date: Tue, 9 Dec 2014 21:46:30 +0900
9ecd5b8
Subject: [PATCH] unit: update unit dropin paths and time when dropin file is
9ecd5b8
 written.
9ecd5b8
9ecd5b8
If a unit is set property by "systemctl set-property", a new dropin
9ecd5b8
file is generated. But the unit's dropin_paths and dropin_mtime are
9ecd5b8
not updated. So the unit is shown as need daemon reload.
9ecd5b8
Update unit dropin_paths and dropin_mtime also when dropin file is
9ecd5b8
written.
9ecd5b8
9ecd5b8
(cherry picked from commit adb76a701d870b980f7949bcfece2c1547b4976d)
9ecd5b8
---
9ecd5b8
 src/core/unit.c | 21 +++++++++++++++++++--
9ecd5b8
 1 file changed, 19 insertions(+), 2 deletions(-)
9ecd5b8
9ecd5b8
diff --git a/src/core/unit.c b/src/core/unit.c
9ecd5b8
index 489ea1e502..8bf026f11c 100644
9ecd5b8
--- a/src/core/unit.c
9ecd5b8
+++ b/src/core/unit.c
9ecd5b8
@@ -3172,7 +3172,7 @@ static int unit_drop_in_file(Unit *u,
9ecd5b8
 
9ecd5b8
 int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
9ecd5b8
 
9ecd5b8
-        _cleanup_free_ char *dir = NULL;
9ecd5b8
+        _cleanup_free_ char *dir = NULL, *p = NULL, *q = NULL;
9ecd5b8
         int r;
9ecd5b8
 
9ecd5b8
         assert(u);
9ecd5b8
@@ -3184,7 +3184,24 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
9ecd5b8
         if (r < 0)
9ecd5b8
                 return r;
9ecd5b8
 
9ecd5b8
-        return write_drop_in(dir, u->id, 50, name, data);
9ecd5b8
+        r = write_drop_in(dir, u->id, 50, name, data);
9ecd5b8
+        if (r < 0)
9ecd5b8
+                return r;
9ecd5b8
+
9ecd5b8
+        r = drop_in_file(dir, u->id, 50, name, &p, &q);
9ecd5b8
+        if (r < 0)
9ecd5b8
+                return r;
9ecd5b8
+
9ecd5b8
+        r = strv_extend(&u->dropin_paths, q);
9ecd5b8
+        if (r < 0)
9ecd5b8
+                return r;
9ecd5b8
+
9ecd5b8
+        strv_sort(u->dropin_paths);
9ecd5b8
+        strv_uniq(u->dropin_paths);
9ecd5b8
+
9ecd5b8
+        u->dropin_mtime = now(CLOCK_REALTIME);
9ecd5b8
+
9ecd5b8
+        return 0;
9ecd5b8
 }
9ecd5b8
 
9ecd5b8
 int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) {