core: simplify unit_need_daemon_reload() a bit
And let's make it more accurate: if we have acquire the list of unit drop-ins, then let's do a full comparison against the old list we already have, and if things differ in any way, we know we have to reload. This makes sure we detect changes to drop-in directories in more cases.
This commit is contained in:
+10
-18
@@ -2968,32 +2968,24 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime) {
|
|||||||
bool unit_need_daemon_reload(Unit *u) {
|
bool unit_need_daemon_reload(Unit *u) {
|
||||||
_cleanup_strv_free_ char **t = NULL;
|
_cleanup_strv_free_ char **t = NULL;
|
||||||
char **path;
|
char **path;
|
||||||
unsigned loaded_cnt, current_cnt;
|
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
|
|
||||||
if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime) ||
|
if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime))
|
||||||
fragment_mtime_newer(u->source_path, u->source_mtime))
|
return true;
|
||||||
|
|
||||||
|
if (fragment_mtime_newer(u->source_path, u->source_mtime))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
(void) unit_find_dropin_paths(u, &t);
|
(void) unit_find_dropin_paths(u, &t);
|
||||||
loaded_cnt = strv_length(t);
|
if (!strv_equal(u->dropin_paths, t))
|
||||||
current_cnt = strv_length(u->dropin_paths);
|
return true;
|
||||||
|
|
||||||
if (loaded_cnt == current_cnt) {
|
STRV_FOREACH(path, u->dropin_paths)
|
||||||
if (loaded_cnt == 0)
|
if (fragment_mtime_newer(*path, u->dropin_mtime))
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
if (strv_overlap(u->dropin_paths, t)) {
|
return false;
|
||||||
STRV_FOREACH(path, u->dropin_paths)
|
|
||||||
if (fragment_mtime_newer(*path, u->dropin_mtime))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unit_reset_failed(Unit *u) {
|
void unit_reset_failed(Unit *u) {
|
||||||
|
|||||||
Reference in New Issue
Block a user