[systemd-devel] [PATCH] unit: update unit dropin paths and time when dropin file is written.

2014-12-09 Thread WaLyong Cho
If a unit is set property by systemctl set-property, a new dropin
file is generated. But the unit's dropin_paths and dropin_mtime are
not updated. So the unit is shown as need daemon reload.
Update unit dropin_paths and dropin_mtime also when dropin file is
written.
---
 src/core/unit.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index 43280ec..b3b0892 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3272,7 +3272,7 @@ static int unit_drop_in_file(Unit *u,
 
 int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, 
const char *data) {
 
-_cleanup_free_ char *dir = NULL;
+_cleanup_free_ char *dir = NULL, *p = NULL, *q = NULL;
 int r;
 
 assert(u);
@@ -3284,7 +3284,24 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode 
mode, const char *name, co
 if (r  0)
 return r;
 
-return write_drop_in(dir, u-id, 50, name, data);
+r = write_drop_in(dir, u-id, 50, name, data);
+if (r  0)
+return r;
+
+r = drop_in_file(dir, u-id, 50, name, p, q);
+if (r  0)
+return r;
+
+r = strv_extend(u-dropin_paths, q);
+if (r  0)
+return r;
+
+strv_sort(u-dropin_paths);
+strv_uniq(u-dropin_paths);
+
+u-dropin_mtime = now(CLOCK_REALTIME);
+
+return 0;
 }
 
 int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char 
*name, const char *format, ...) {
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] unit: update unit dropin paths and time when dropin file is written.

2014-12-09 Thread Lennart Poettering
On Tue, 09.12.14 21:46, WaLyong Cho (walyong@samsung.com) wrote:

 If a unit is set property by systemctl set-property, a new dropin
 file is generated. But the unit's dropin_paths and dropin_mtime are
 not updated. So the unit is shown as need daemon reload.
 Update unit dropin_paths and dropin_mtime also when dropin file is
 written.

Looks good! Thanks! Applied!

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel