From: Miroslav Lichvar Date: Thu, 25 Feb 2021 15:51:23 +0000 (+0100) Subject: refclock: warn if maxlockage is too small X-Git-Tag: 4.1-pre1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62f2d5736daac8d72ded5dbb6e65e83d489b03bb;p=thirdparty%2Fchrony.git refclock: warn if maxlockage is too small Log a warning message if the interval covered by the maxlockage at the PPS rate of a refclock is shorter than driver poll of the locked refclock. Reported-by: Matt Corallo --- diff --git a/refclock.c b/refclock.c index e1eedffe..5cc2ca26 100644 --- a/refclock.c +++ b/refclock.c @@ -267,7 +267,7 @@ RCL_AddRefclock(RefclockParameters *params) void RCL_StartRefclocks(void) { - unsigned int i, j, n; + unsigned int i, j, n, lock_index; n = ARR_GetSize(refclocks); @@ -277,13 +277,28 @@ RCL_StartRefclocks(void) SRC_SetActive(inst->source); inst->timeout_id = SCH_AddTimeoutByDelay(0.0, poll_timeout, (void *)inst); - if (inst->lock_ref) { - /* Replace lock refid with index to refclocks */ - for (j = 0; j < n && get_refclock(j)->ref_id != inst->lock_ref; j++) - ; - inst->lock_ref = j < n ? j : -1; - } else - inst->lock_ref = -1; + /* Replace lock refid with the refclock's index, or -1 if not valid */ + + lock_index = -1; + + if (inst->lock_ref != 0) { + for (j = 0; j < n; j++) { + RCL_Instance inst2 = get_refclock(j); + + if (inst->lock_ref != inst2->ref_id) + continue; + + if (inst->driver->poll && inst2->driver->poll && + (double)inst->max_lock_age / inst->pps_rate < UTI_Log2ToDouble(inst2->driver_poll)) + LOG(LOGS_WARN, "%s maxlockage too small for %s", + UTI_RefidToString(inst->ref_id), UTI_RefidToString(inst2->ref_id)); + + lock_index = j; + break; + } + } + + inst->lock_ref = lock_index; } }