summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-03 14:08:23 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-03 14:08:23 -0400
commitd43bbb52de220e6008a649b128fe32da995b5e1e (patch)
tree19b6acdf82fe911dd854cee2feaee53cfc34b884 /src/core/unit.c
parent6254be5def638194f21c2f47461d5acaa2a97b7f (diff)
Revert "Do not report masked units as changed (#2921)"
This reverts commit 6d10d308c6cd16528ef58fa4f5822aef936862d3. It got squashed by mistake.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 4ace6b075b..5b8b0130bd 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2951,36 +2951,34 @@ int unit_coldplug(Unit *u) {
return 0;
}
-static bool fragment_mtime_changed(const char *path, usec_t mtime) {
- struct stat st;
-
- if (!path)
- return false;
-
- if (stat(path, &st) < 0)
- /* What, cannot access this anymore? */
- return true;
-
- if (mtime > 0)
- /* For non-empty files check the 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;
-
- return false;
-}
-
bool unit_need_daemon_reload(Unit *u) {
_cleanup_strv_free_ char **t = NULL;
char **path;
+ struct stat st;
unsigned loaded_cnt, current_cnt;
assert(u);
- if (fragment_mtime_changed(u->fragment_path, u->fragment_mtime) ||
- fragment_mtime_changed(u->source_path, u->source_mtime))
- return true;
+ if (u->fragment_path) {
+ zero(st);
+ if (stat(u->fragment_path, &st) < 0)
+ /* What, cannot access this anymore? */
+ return true;
+
+ if (u->fragment_mtime > 0 &&
+ timespec_load(&st.st_mtim) != u->fragment_mtime)
+ return true;
+ }
+
+ if (u->source_path) {
+ zero(st);
+ if (stat(u->source_path, &st) < 0)
+ return true;
+
+ if (u->source_mtime > 0 &&
+ timespec_load(&st.st_mtim) != u->source_mtime)
+ return true;
+ }
(void) unit_find_dropin_paths(u, &t);
loaded_cnt = strv_length(t);
@@ -2991,15 +2989,21 @@ bool unit_need_daemon_reload(Unit *u) {
return false;
if (strv_overlap(u->dropin_paths, t)) {
- STRV_FOREACH(path, u->dropin_paths)
- if (fragment_mtime_changed(*path, u->dropin_mtime))
+ STRV_FOREACH(path, u->dropin_paths) {
+ zero(st);
+ if (stat(*path, &st) < 0)
return true;
- return false;
- }
- }
+ if (u->dropin_mtime > 0 &&
+ timespec_load(&st.st_mtim) > u->dropin_mtime)
+ return true;
+ }
- return true;
+ return false;
+ } else
+ return true;
+ } else
+ return true;
}
void unit_reset_failed(Unit *u) {