]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: avoid unnecessary replacement attempts
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 7 Oct 2020 07:37:41 +0000 (09:37 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 7 Oct 2020 15:27:34 +0000 (17:27 +0200)
In the initial resolving of pool sources try to assign each address only
once. If it fails, it means the address is already used (DNS provided
the same address) or the address is not connectable. The same result can
be expected for other unresolved sources of the pool as they don't have
a real address yet.

ntp_sources.c

index 122f5e4801ddd9696139222eb2092af1a188381c..850f47182d2bc9287d4e82c39c354af72908cfbf 100644 (file)
@@ -444,8 +444,8 @@ process_resolved_name(struct UnresolvedSource *us, IPAddr *ip_addrs, int n_addrs
     DEBUG_LOG("(%d) %s", i + 1, UTI_IPToString(&new_addr.ip_addr));
 
     if (us->pool_id != INVALID_POOL) {
-      /* In the pool resolving mode, try to replace all sources from
-         the pool which don't have a real address yet */
+      /* In the pool resolving mode, try to replace a source from
+         the pool which does not have a real address yet */
       for (j = 0; j < ARR_GetSize(records); j++) {
         record = get_record(j);
         if (!record->remote_addr || record->pool_id != us->pool_id ||
@@ -454,7 +454,8 @@ process_resolved_name(struct UnresolvedSource *us, IPAddr *ip_addrs, int n_addrs
         old_addr = *record->remote_addr;
         new_addr.port = old_addr.port;
         if (replace_source_connectable(&old_addr, &new_addr))
-          break;
+          ;
+        break;
       }
     } else {
       new_addr.port = us->address.port;