Blame SOURCES/chrony-preferselect.patch

bd02a2
commit f456cd57b93695b1a9bd792ed084c62f9ffa7c9f
bd02a2
Author: Miroslav Lichvar <mlichvar@redhat.com>
bd02a2
Date:   Tue Jan 21 17:18:48 2014 +0100
bd02a2
bd02a2
    Fix selecting of sources with prefer option
bd02a2
    
bd02a2
    List of selectable sources that is used in combining was trimmed to
bd02a2
    sources with prefer option, but scoring algorithm considered all
bd02a2
    selectable sources. When a source without prefer was selected and
bd02a2
    no source was combined, it caused assertion failure.
bd02a2
bd02a2
diff --git a/sources.c b/sources.c
bd02a2
index 6c6a5bb..de07bd3 100644
bd02a2
--- a/sources.c
bd02a2
+++ b/sources.c
bd02a2
@@ -503,7 +503,7 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset,
bd02a2
 void
bd02a2
 SRC_SelectSource(uint32_t match_refid)
bd02a2
 {
bd02a2
-  int i, j, index, old_selected_index;
bd02a2
+  int i, j, index, old_selected_index, sel_prefer;
bd02a2
   struct timeval now, ref_time;
bd02a2
   double src_offset, src_offset_sd, src_frequency, src_skew;
bd02a2
   double src_root_delay, src_root_dispersion;
bd02a2
@@ -811,6 +811,9 @@ SRC_SelectSource(uint32_t match_refid)
bd02a2
         }
bd02a2
         if (j > 0) {
bd02a2
           n_sel_sources = j;
bd02a2
+          sel_prefer = 1;
bd02a2
+        } else {
bd02a2
+          sel_prefer = 0;
bd02a2
         }
bd02a2
 
bd02a2
         /* Now find minimum stratum.  If none are left now,
bd02a2
@@ -843,7 +846,8 @@ SRC_SelectSource(uint32_t match_refid)
bd02a2
         for (i = 0; i < n_sources; i++) {
bd02a2
 
bd02a2
           /* Reset score for non-selectable sources */
bd02a2
-          if (sources[i]->status != SRC_SELECTABLE) {
bd02a2
+          if (sources[i]->status != SRC_SELECTABLE ||
bd02a2
+              (sel_prefer && sources[i]->sel_option != SRC_SelectPrefer)) {
bd02a2
             sources[i]->sel_score = 1.0;
bd02a2
             sources[i]->outlier = OUTLIER_PENALTY;
bd02a2
             continue;