Commit 4dae1e34 authored by Alessandro Rubini's avatar Alessandro Rubini

wrs-time: change Unix time too

time_operations->set() is rarely called for the white rabbit switch.
Besides the special case with a NULL time pointer, it is only called
by the normal servo, before WR-Mode is activated on the relevant link.
This happens once only.

In this situation, we should set Unix time, in addition to changing
the WR timers. The code, as laid out would change Unix time upon
repeated invocation of this function, but not the first time. Thus,
we risked keeping a wrong system time even if WR synced to the
external world.  This means syslog messages would be stamped at
January 1970.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1ac2d714
......@@ -208,12 +208,13 @@ static int wrs_time_set(struct pp_instance *ppi, TimeInternal *t)
if (abs(diff.nanoseconds) > 10 * 1000 * 1000) {
pp_diag(ppi, time, 1, "%s: adjusting nanoseconds: %li\n",
__func__, (long)diff.nanoseconds);
wrs_adjust_counters(0, diff.nanoseconds);
return 0;
diff.seconds = 0;
} else {
pp_diag(ppi, time, 1, "%s: adjusting seconds: %li\n",
__func__, (long)diff.seconds);
diff.nanoseconds = 0;
}
pp_diag(ppi, time, 1, "%s: adjusting seconds: %li\n",
__func__, (long)diff.seconds);
wrs_adjust_counters(diff.seconds, 0);
wrs_adjust_counters(diff.seconds, diff.nanoseconds);
/* Finally, set unix time too */
unix_time_ops.set(ppi, t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment