From 28c9e66f5b75be60a5bcaafc6987dbfb4a4a5ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 30 Jun 2021 16:47:22 +0200 Subject: [PATCH] refclock: Fix poll counting for refclocks that do polling and event driven timekeeping The RTC refclock support both modes of timekeeping (depending on hardware capabilities). As the driver data is const there is a poll callback even in interrupt mode. So only count poll calls that return non-zero and count provided timestamps in the respective functions if they are not called from the driver's poll routine. --- refclock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/refclock.c b/refclock.c index 9f098f2..5917d0b 100644 --- a/refclock.c +++ b/refclock.c @@ -64,6 +64,7 @@ struct RCL_Instance_Record { int driver_poll; int driver_polled; int poll; + int inpoll; int leap_status; int local; int pps_forced; @@ -177,6 +178,7 @@ RCL_AddRefclock(RefclockParameters *params) inst->driver_parameter_length = 0; inst->driver_poll = params->driver_poll; inst->poll = params->poll; + inst->inpoll = 0; inst->driver_polled = 0; inst->leap_status = LEAP_Normal; inst->local = params->local; @@ -505,7 +507,7 @@ RCL_AddSample(RCL_Instance instance, struct timespec *sample_time, log_sample(instance, &cooked_time, 0, 0, raw_offset, offset, dispersion); /* for logging purposes */ - if (!instance->driver->poll) + if (!instance->inpoll) instance->driver_polled++; return 1; @@ -662,7 +664,7 @@ RCL_AddCookedPulse(RCL_Instance instance, struct timespec *cooked_time, offset, dispersion); /* for logging purposes */ - if (!instance->driver->poll) + if (!instance->inpoll) instance->driver_polled++; return 1; @@ -788,7 +790,9 @@ poll_timeout(void *arg) if (inst->driver->poll) { poll = inst->driver_poll; + inst->inpoll = 1; inst->driver->poll(inst); + inst->inpoll = 0; inst->driver_polled++; }