From: Miroslav Lichvar Date: Fri, 1 Apr 2016 07:37:49 +0000 (+0200) Subject: sources: log error when local refid is unknown in orphan mode X-Git-Tag: 2.4-pre1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6accd19eb355ec61ca603540ee8f00b2956112bc;p=thirdparty%2Fchrony.git sources: log error when local refid is unknown in orphan mode --- diff --git a/sources.c b/sources.c index df3f7a0b..b3a2e97d 100644 --- a/sources.c +++ b/sources.c @@ -731,13 +731,17 @@ SRC_SelectSource(SRC_Instance updated_inst) } /* If no selectable source is available, consider the orphan source */ - if (!n_sel_sources && orphan_source != INVALID_SOURCE && - sources[orphan_source]->ref_id < - NSR_GetLocalRefid(sources[orphan_source]->ip_addr)) { - sources[orphan_source]->status = SRC_OK; - n_sel_sources = 1; - DEBUG_LOG(LOGF_Sources, "selecting orphan refid=%"PRIx32, - sources[orphan_source]->ref_id); + if (!n_sel_sources && orphan_source != INVALID_SOURCE) { + uint32_t local_ref_id = NSR_GetLocalRefid(sources[orphan_source]->ip_addr); + + if (!local_ref_id) { + LOG(LOGS_ERR, LOGF_Sources, "Unknown local refid in orphan mode"); + } else if (sources[orphan_source]->ref_id < local_ref_id) { + sources[orphan_source]->status = SRC_OK; + n_sel_sources = 1; + DEBUG_LOG(LOGF_Sources, "selecting orphan refid=%"PRIx32, + sources[orphan_source]->ref_id); + } } for (i = 0; i < n_sources; i++) {