From 6e5513c80bc0e962e8c0bb4b9af9b4b79e194971 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 14 Mar 2024 15:32:28 +0100 Subject: [PATCH] ntp: don't keep refresh requests in list of unresolved sources The refresh command adds requests to reresolve addresses of all sources. If some sources didn't have an IP address resolved yet, the corresponding requests were not removed after failed resolving. Repeated refresh commands increased the number of requests and number of calls of the system resolver, which might not be caching DNS responses. Remove all refresh requests from the list after resolving attempt to fix that. Reported-by: t.barnewski@avm.de Fixes: d7e3ad17ff7a ("ntp: create sources for unresolved addresses") --- ntp_sources.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ntp_sources.c b/ntp_sources.c index 396175d..1257f57 100644 --- a/ntp_sources.c +++ b/ntp_sources.c @@ -638,8 +638,10 @@ name_resolve_handler(DNS_Status status, int n_addrs, IPAddr *ip_addrs, void *any next = us->next; /* Don't repeat the resolving if it (permanently) failed, it was a - replacement of a real address, or all addresses are already resolved */ - if (status == DNS_Failure || UTI_IsIPReal(&us->address.ip_addr) || is_resolved(us)) + replacement of a real address, a refreshment, or all addresses are + already resolved */ + if (status == DNS_Failure || UTI_IsIPReal(&us->address.ip_addr) || + us->refreshment || is_resolved(us)) remove_unresolved_source(us); /* If a restart was requested and this was the last source in the list,