summaryrefslogtreecommitdiffstats
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2019-09-05 16:53:50 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-09-16 15:53:52 +0200
commit5a1c1b534fe13e60ef9bce0dc680ad6f2a0c577f (patch)
tree4bd66ad12b1d5584472255d19d713e2e8ddf42c7 /src/core/load-fragment.c
parentMerge pull request #13551 from keszybz/ll-no-default-route (diff)
downloadsystemd-5a1c1b534fe13e60ef9bce0dc680ad6f2a0c577f.tar.xz
systemd-5a1c1b534fe13e60ef9bce0dc680ad6f2a0c577f.zip
core: restore initialization of u->source_mtime
During the rework of unit file loading, commit e8630e695232bdfc dropped the initialization u->source_mtime. This had the bad side effect that generated units always needed daemon reloading.
Diffstat (limited to '')
-rw-r--r--src/core/load-fragment.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 8eaf8b33e9..a7951a5757 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -4594,6 +4594,7 @@ static int merge_by_names(Unit **u, Set *names, const char *id) {
int unit_load_fragment(Unit *u) {
const char *fragment;
_cleanup_set_free_free_ Set *names = NULL;
+ struct stat st;
int r;
assert(u);
@@ -4625,7 +4626,6 @@ int unit_load_fragment(Unit *u) {
if (fragment) {
/* Open the file, check if this is a mask, otherwise read. */
_cleanup_fclose_ FILE *f = NULL;
- struct stat st;
/* Try to open the file name. A symlink is OK, for example for linked files or masks. We
* expect that all symlinks within the lookup paths have been already resolved, but we don't
@@ -4660,6 +4660,13 @@ int unit_load_fragment(Unit *u) {
}
}
+ if (u->source_path) {
+ if (stat(u->source_path, &st) >= 0)
+ u->source_mtime = timespec_load(&st.st_mtim);
+ else
+ u->source_mtime = 0;
+ }
+
/* We do the merge dance here because for some unit types, the unit might have aliases which are not
* declared in the file system. In particular, this is true (and frequent) for device and swap units.
*/