From 26b87b844d7c026b656387eb42be2727ad45a942 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 13 Apr 2016 11:43:36 +0200 Subject: [PATCH] sources: consider only reachable orphans for selection Ignore orphan sources that are unreachable (but still have usable stats) to have a quick and consistent source selection between orphans. This also fixes the "Unknown local refid in orphan mode" error appearing when a selected orphan source is removed, as the source is marked as unreachable and the selection runs with disabled NTP instance before the source instance is actually removed. --- sources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.c b/sources.c index b3a2e97..79f72cf 100644 --- a/sources.c +++ b/sources.c @@ -719,7 +719,7 @@ SRC_SelectSource(SRC_Instance updated_inst) if (si->stratum >= orphan_stratum && sources[i]->type == SRC_NTP) { sources[i]->status = SRC_ORPHAN; - if (si->stratum == orphan_stratum && + if (si->stratum == orphan_stratum && sources[i]->reachability && (orphan_source == INVALID_SOURCE || sources[i]->ref_id < sources[orphan_source]->ref_id)) orphan_source = i;