]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: reorder unsynchronised source status
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Apr 2024 12:45:23 +0000 (14:45 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 30 Apr 2024 13:52:18 +0000 (15:52 +0200)
In the source selection, check for the unsynchronized leap status after
getting sourcestats data. The unsynchronized source status is supposed
to indicate an unsynchronized source that is providing samples, not a
source which doesn't have any samples.

Also, fix the comment describing the status.

Fixes: 4c29f8888c76 ("sources: handle unsynchronized sources in selection")
doc/chronyc.adoc
sources.c
test/system/007-cmdmon

index 8c5668a192e017344acd08c45c10b371e2474c88..1a843c3835e9922d706257ffdb7b2062bdd3fd3a 100644 (file)
@@ -459,8 +459,8 @@ states are reported.
 The following states indicate the source is not considered selectable for
 synchronisation:
 * _N_ - has the *noselect* option.
-* _s_ - is not synchronised.
 * _M_ - does not have enough measurements.
+* _s_ - is not synchronised.
 * _d_ - has a root distance larger than the maximum distance (configured by the
         <<chrony.conf.adoc#maxdistance,*maxdistance*>> directive).
 * _~_ - has a jitter larger than the maximum jitter (configured by the
index e7ec4b82f7c492215670758b21f5ccbd2bc14944..b728431c33f6d50c39bf0317622d0c37a0f9b8b6 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -68,8 +68,8 @@ struct SelectInfo {
 typedef enum {
   SRC_OK,               /* OK so far, not a final status! */
   SRC_UNSELECTABLE,     /* Has noselect option set */
-  SRC_UNSYNCHRONISED,   /* Provides samples but not unsynchronised */
   SRC_BAD_STATS,        /* Doesn't have valid stats data */
+  SRC_UNSYNCHRONISED,   /* Provides samples, but not synchronised */
   SRC_BAD_DISTANCE,     /* Has root distance longer than allowed maximum */
   SRC_JITTERY,          /* Had std dev larger than allowed maximum */
   SRC_WAITS_STATS,      /* Others have bad stats, selection postponed */
@@ -913,12 +913,6 @@ SRC_SelectSource(SRC_Instance updated_inst)
       continue;
     }
 
-    /* Ignore sources which are not synchronised */
-    if (sources[i]->leap == LEAP_Unsynchronised) {
-      mark_source(sources[i], SRC_UNSYNCHRONISED);
-      continue;
-    }
-
     si = &sources[i]->sel_info;
     SST_GetSelectionData(sources[i]->stats, &now,
                          &si->lo_limit, &si->hi_limit, &si->root_distance,
@@ -933,6 +927,12 @@ SRC_SelectSource(SRC_Instance updated_inst)
       continue;
     }
 
+    /* Ignore sources which are not synchronised */
+    if (sources[i]->leap == LEAP_Unsynchronised) {
+      mark_source(sources[i], SRC_UNSYNCHRONISED);
+      continue;
+    }
+
     /* Include extra dispersion in the root distance of sources that don't
        have new samples (the last sample is older than span of all samples) */
     if (first_sample_ago < 2.0 * si->last_sample_ago) {
@@ -1796,10 +1796,10 @@ get_status_char(SRC_Status status)
   switch (status) {
     case SRC_UNSELECTABLE:
       return 'N';
-    case SRC_UNSYNCHRONISED:
-      return 's';
     case SRC_BAD_STATS:
       return 'M';
+    case SRC_UNSYNCHRONISED:
+      return 's';
     case SRC_BAD_DISTANCE:
       return 'd';
     case SRC_JITTERY:
index 953b4f356137a21e41f3f792e61ce653db8be0e0..954a15bb38dcf5a9099c0db447a9b8fc8f958801 100755 (executable)
@@ -107,7 +107,7 @@ Total HW RX     : 0$" || test_fail
 run_chronyc "selectdata" || test_fail
 check_chronyc_output "^S Name/IP Address        Auth COpts EOpts Last Score     Interval  Leap
 =======================================================================
-s 127\.0\.0\.1                 N -PTR- -PTR-    0   1\.0    \+0ns    \+0ns  \?$" || test_fail
+M 127\.0\.0\.1                 N -PTR- -PTR-    0   1\.0    \+0ns    \+0ns  \?$" || test_fail
 
 run_chronyc "serverstats" || test_fail
 check_chronyc_output "^NTP packets received       : [0-9]+