From b734340596a27c067a27bc0774ba30d7dd22b553 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 25 Mar 2026 22:18:12 +0100 Subject: [PATCH] resolved: move resetting of {etc_hosts|static_records}_last to manager_dispatch_reload_signal() This addresses https://github.com/systemd/systemd/pull/41213#pullrequestreview-4002247053 which I somehow missed earlier. Claude found a real issue for the case of manager_etc_hosts_flush(). We'll do the equivalent change in manager_static_records_flush() too, even though it's not really necessary there, simply to keep things nicely mirrored. --- src/resolve/resolved-etc-hosts.c | 3 ++- src/resolve/resolved-manager.c | 3 +++ src/resolve/resolved-static-records.c | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c index 00c76a9977f..b38c011e7c6 100644 --- a/src/resolve/resolved-etc-hosts.c +++ b/src/resolve/resolved-etc-hosts.c @@ -72,7 +72,8 @@ void etc_hosts_clear(EtcHosts *hosts) { void manager_etc_hosts_flush(Manager *m) { etc_hosts_clear(&m->etc_hosts); m->etc_hosts_stat = (struct stat) {}; - m->etc_hosts_last = USEC_INFINITY; + /* NB: We do not reset m->etc_hosts_last here, because manager_etc_hosts_read() calls us and needs it + * to stay in effect for the reload suppression to work */ } static int parse_line(EtcHosts *hosts, unsigned nr, const char *line) { diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 25a51ed02b0..e96ae4393c6 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -664,6 +664,9 @@ static int manager_dispatch_reload_signal(sd_event_source *s, const struct signa manager_etc_hosts_flush(m); manager_static_records_flush(m); + m->etc_hosts_last = USEC_INFINITY; + m->static_records_last = USEC_INFINITY; + manager_set_defaults(m); r = dns_trust_anchor_load(&m->trust_anchor); diff --git a/src/resolve/resolved-static-records.c b/src/resolve/resolved-static-records.c index 0f2d09b324f..d905d507d6a 100644 --- a/src/resolve/resolved-static-records.c +++ b/src/resolve/resolved-static-records.c @@ -222,5 +222,4 @@ void manager_static_records_flush(Manager *m) { m->static_records = hashmap_free(m->static_records); m->static_records_stat = set_free(m->static_records_stat); - m->static_records_last = USEC_INFINITY; } -- 2.47.3