reference: schedule fallback drift even when synchronized

After update to NTPv4 the synchronized status doesn't change when
sources are unreachable, start fallbackdrift timeout on reference update
too.
This commit is contained in:
Miroslav Lichvar 2015-03-26 12:32:00 +01:00
parent d9a84d24cf
commit 2af6f8cf78
2 changed files with 12 additions and 11 deletions

View file

@ -1637,14 +1637,13 @@ the program exits. (See the dumpdir command above).
@subsection fallbackdrift
Fallback drifts are long-term averages of the system clock drift
calculated over exponentially increasing intervals. They are used
when the clock is unsynchronised to avoid quickly drifting away from
true time if there was a short-term deviation in drift before the
synchronisation was lost.
when the clock is no longer synchronised to avoid quickly drifting
away from true time if there was a short-term deviation in the drift
before the synchronisation was lost.
The directive specifies the minimum and maximum interval for how long
the system clock has to be unsynchronised to switch between fallback
drifts. They are defined as a power of 2 (in seconds). The syntax is
as follows
The directive specifies the minimum and maximum interval since last
clock update to switch between fallback drifts. They are defined as a
power of 2 (in seconds). The syntax is as follows
@example
fallbackdrift 16 19
@ -1652,13 +1651,13 @@ fallbackdrift 16 19
In this example, the minimum interval is 16 (18 hours) and maximum
interval is 19 (6 days). The system clock frequency will be set to
the first fallback 18 hours after the synchronisation was lost, to the
the first fallback 18 hours after last clock update, to the
second after 36 hours, etc. This might be a good setting to cover
daily and weekly temperature fluctuations.
By default (or if the specified maximum or minimum is 0), no fallbacks
will be used and the clock frequency will stay at the last value
calculated before synchronisation was lost.
are used and the clock frequency changes only with new measurements from
NTP, reference clocks or manual input.
@c }}}
@c {{{ generatecommandkey
@node generatecommandkey directive

View file

@ -457,11 +457,12 @@ update_fb_drifts(double freq_ppm, double update_interval)
static void
fb_drift_timeout(void *arg)
{
assert(are_we_synchronised == 0);
assert(next_fb_drift >= fb_drift_min && next_fb_drift <= fb_drift_max);
fb_drift_timeout_id = -1;
DEBUG_LOG(LOGF_Reference, "Fallback drift %d active: %f ppm",
next_fb_drift, fb_drifts[next_fb_drift - fb_drift_min].freq);
LCL_SetAbsoluteFrequency(fb_drifts[next_fb_drift - fb_drift_min].freq);
REF_SetUnsynchronised();
}
@ -1071,6 +1072,7 @@ REF_SetReference(int stratum,
/* Update fallback drifts */
if (fb_drifts) {
update_fb_drifts(abs_freq_ppm, update_interval);
schedule_fb_drift(&now);
}
last_ref_update_interval = update_interval;