Skip to content

Commit ab932a6

Browse files
committed
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.
1 parent 87ec20e commit ab932a6

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

src/core/unit.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,32 +2968,24 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime) {
29682968
bool unit_need_daemon_reload(Unit *u) {
29692969
_cleanup_strv_free_ char **t = NULL;
29702970
char **path;
2971-
unsigned loaded_cnt, current_cnt;
29722971

29732972
assert(u);
29742973

2975-
if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime) ||
2976-
fragment_mtime_newer(u->source_path, u->source_mtime))
2974+
if (fragment_mtime_newer(u->fragment_path, u->fragment_mtime))
29772975
return true;
29782976

2979-
(void) unit_find_dropin_paths(u, &t);
2980-
loaded_cnt = strv_length(t);
2981-
current_cnt = strv_length(u->dropin_paths);
2982-
2983-
if (loaded_cnt == current_cnt) {
2984-
if (loaded_cnt == 0)
2985-
return false;
2977+
if (fragment_mtime_newer(u->source_path, u->source_mtime))
2978+
return true;
29862979

2987-
if (strv_overlap(u->dropin_paths, t)) {
2988-
STRV_FOREACH(path, u->dropin_paths)
2989-
if (fragment_mtime_newer(*path, u->dropin_mtime))
2990-
return true;
2980+
(void) unit_find_dropin_paths(u, &t);
2981+
if (!strv_equal(u->dropin_paths, t))
2982+
return true;
29912983

2992-
return false;
2993-
}
2994-
}
2984+
STRV_FOREACH(path, u->dropin_paths)
2985+
if (fragment_mtime_newer(*path, u->dropin_mtime))
2986+
return true;
29952987

2996-
return true;
2988+
return false;
29972989
}
29982990

29992991
void unit_reset_failed(Unit *u) {

0 commit comments

Comments
 (0)