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.
This commit is contained in:
Miroslav Lichvar 2016-04-13 11:43:36 +02:00
parent 1834ee05e5
commit 26b87b844d

View file

@ -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;