]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: keep synchronized status with unreachable/unselectable sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Oct 2014 14:26:05 +0000 (16:26 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 20 Oct 2014 09:02:07 +0000 (11:02 +0200)
Following RFC 5905, don't call REF_SetUnsynchronised() when there are no
reachable or selectable sources. It's up to the client to consider the
source unsynchronized when the root distance exceeds a threshold.

The unsynchronized status is still set when no majority is reached.

sources.c

index 794ba2a1e6825bbad7d21a57ecec49f4020651b1..04befbc46658786d64e729da7c8fc91005ee3fcc 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -571,7 +571,7 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset,
 void
 SRC_SelectSource(SRC_Instance updated_inst)
 {
-  int i, j, index, old_selected_index, sel_prefer;
+  int i, j, index, sel_prefer;
   struct timeval now, ref_time;
   double src_offset, src_offset_sd, src_frequency, src_skew;
   double src_root_delay, src_root_dispersion;
@@ -588,7 +588,6 @@ SRC_SelectSource(SRC_Instance updated_inst)
   double max_score;
 
   NTP_Leap leap_status = LEAP_Normal;
-  old_selected_index = selected_source_index;
 
   if (updated_inst)
     updated_inst->updates++;
@@ -598,7 +597,6 @@ SRC_SelectSource(SRC_Instance updated_inst)
     if (selected_source_index != INVALID_SOURCE) {
       log_selection_message("Can't synchronise: no sources", NULL);
       selected_source_index = INVALID_SOURCE;
-      REF_SetUnsynchronised();
     }
     return;
   }
@@ -748,6 +746,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
 
       if (selected_source_index != INVALID_SOURCE) {
         log_selection_message("Can't synchronise: no majority", NULL);
+        REF_SetUnsynchronised();
       }
       selected_source_index = INVALID_SOURCE;
 
@@ -990,11 +989,6 @@ SRC_SelectSource(SRC_Instance updated_inst)
     }
     selected_source_index = INVALID_SOURCE;
   }
-
-  if (selected_source_index == INVALID_SOURCE &&
-      selected_source_index != old_selected_index) {
-    REF_SetUnsynchronised();
-  }
 }
 
 /* ================================================== */