]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: enable no majority message before first selection
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 26 Jan 2023 15:12:26 +0000 (16:12 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 26 Jan 2023 15:15:47 +0000 (16:15 +0100)
Add a separate flag to allow the "no majority" message to be logged even
before the first successful selection.

sources.c

index 010a1de87eed9ef2669c5c15cabbcad30dd3ec27..66c73ad45ab3fa51b1de28e7478a05cac26f7d72 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -165,6 +165,8 @@ static int max_n_sources; /* Capacity of the table */
 static int selected_source_index; /* Which source index is currently
                                      selected (set to INVALID_SOURCE
                                      if no current valid reference) */
+static int reported_no_majority;  /* Flag to avoid repeated log message
+                                     about no majority */
 
 /* Score needed to replace the currently selected source */
 #define SCORE_LIMIT 10.0
@@ -1083,8 +1085,12 @@ SRC_SelectSource(SRC_Instance updated_inst)
       (best_trust_depth > 0 && best_trust_depth <= n_sel_trust_sources / 2)) {
     /* Could not even get half the reachable (trusted) sources to agree */
 
-    if (selected_source_index != INVALID_SOURCE) {
+    if (!reported_no_majority) {
       log_selection_message(LOGS_WARN, "Can't synchronise: no majority", NULL);
+      reported_no_majority = 1;
+    }
+
+    if (selected_source_index != INVALID_SOURCE) {
       REF_SetUnsynchronised();
       selected_source_index = INVALID_SOURCE;
     }
@@ -1259,6 +1265,8 @@ SRC_SelectSource(SRC_Instance updated_inst)
       sources[i]->sel_score = 1.0;
       sources[i]->distant = 0;
     }
+
+    reported_no_majority = 0;
   }
 
   mark_source(sources[selected_source_index], SRC_SELECTED);