diff --git a/src/core/unit.c b/src/core/unit.c index 3f24cf27f4..8ac0aad2d7 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3796,8 +3796,6 @@ static bool fragment_mtime_newer(const char *path, usec_t mtime, bool path_maske } bool unit_need_daemon_reload(Unit *u) { - _cleanup_strv_free_ char **dropins = NULL; - assert(u); assert(u->manager); @@ -3813,16 +3811,20 @@ bool unit_need_daemon_reload(Unit *u) { if (fragment_mtime_newer(u->source_path, u->source_mtime, false)) return true; - if (u->load_state == UNIT_LOADED) - (void) unit_find_dropin_paths(u, &dropins); - if (!strv_equal(u->dropin_paths, dropins)) - return true; + if (u->load_state == UNIT_LOADED) { + _cleanup_strv_free_ char **dropins = NULL; - /* … any drop-ins that are masked are simply omitted from the list. */ - STRV_FOREACH(path, u->dropin_paths) - if (fragment_mtime_newer(*path, u->dropin_mtime, false)) + (void) unit_find_dropin_paths(u, &dropins); + + if (!strv_equal(u->dropin_paths, dropins)) return true; + /* … any drop-ins that are masked are simply omitted from the list. */ + STRV_FOREACH(path, u->dropin_paths) + if (fragment_mtime_newer(*path, u->dropin_mtime, false)) + return true; + } + return false; } diff --git a/test/units/TEST-07-PID1.issue-33672.sh b/test/units/TEST-07-PID1.issue-33672.sh index ab388e32b1..370497c346 100755 --- a/test/units/TEST-07-PID1.issue-33672.sh +++ b/test/units/TEST-07-PID1.issue-33672.sh @@ -37,5 +37,4 @@ systemctl unmask "$UNIT" assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no systemctl mask "$UNIT" -# FIXME: should be "no" -assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" yes +assert_eq "$(systemctl show -P NeedDaemonReload "$UNIT")" no