]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: don't keep refresh requests in list of unresolved sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Mar 2024 14:32:28 +0000 (15:32 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Mar 2024 15:39:41 +0000 (16:39 +0100)
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

index 396175d0e27d20baa6097746a02e13818bc426d3..1257f5775e4a03622b462edfed95fb06a968900a 100644 (file)
@@ -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,