summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-02 14:50:27 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-02 15:10:24 +0200
commit87ec20ef2089712e6c9a9f3ddfba6c5e312694fe (patch)
treea306cb1247e02177440098482d3c64deb90f55f0 /src/core/unit.c
parent072993504e3e4206ae1019f5461a0372f7d82ddf (diff)
core: fix detection whether per-unit drop-ins changed
This fixes fall-out from 6d10d308c6cd16528ef58fa4f5822aef936862d3. Until that commit, do determine whether a daemon reload was required we compare the mtime of the main unit file we loaded with the mtime of it on disk for equality, but for drop-ins we only stored the newest mtime of all of them and then did a "newer-than" comparison. This was brokeni with the above commit, when all checks where changed to be for equality. With this change all checks are now done as "newer-than", fixing the drop-in mtime case. Strictly speaking this will not detect a number of changes that the code before above commit detected, but given that the mtime is unlikely to go backwards, and this is just intended to be a helpful hint anyway, this looks OK in order to keep things simple. Fixes: #3123
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index fd9ecc36ce..b4d313a71b 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2945,7 +2945,7 @@ int unit_coldplug(Unit *u) {
return 0;
}
-static bool fragment_mtime_changed(const char *path, usec_t mtime) {
+static bool fragment_mtime_newer(const char *path, usec_t mtime) {
struct stat st;
if (!path)
@@ -2957,7 +2957,7 @@ static bool fragment_mtime_changed(const char *path, usec_t mtime) {
if (mtime > 0)
/* For non-empty files check the mtime */
- return timespec_load(&st.st_mtim) != mtime;
+ return timespec_load(&st.st_mtim) > mtime;
else if (!null_or_empty(&st))
/* For masked files check if they are still so */
return true;
@@ -2972,8 +2972,8 @@ bool unit_need_daemon_reload(Unit *u) {
assert(u);
- if (fragment_mtime_changed(u->fragment_path, u->fragment_mtime) ||
- fragment_mtime_changed(u->source_path, u->source_mtime))
+ if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime) ||
+ fragment_mtime_newer(u->source_path, u->source_mtime))
return true;
(void) unit_find_dropin_paths(u, &t);
@@ -2986,7 +2986,7 @@ bool unit_need_daemon_reload(Unit *u) {
if (strv_overlap(u->dropin_paths, t)) {
STRV_FOREACH(path, u->dropin_paths)
- if (fragment_mtime_changed(*path, u->dropin_mtime))
+ if (fragment_mtime_newer(*path, u->dropin_mtime))
return true;
return false;