global-functions: $IsTimeSync: reset ntp client when "waiting"

Every now and then the ntp client stays in status "waiting" forever...
This happens if the server answers, but is not accurate enough. Unlike
with connection failure the address is not rotated. (SUP-120012)

Let's reset it... Should help with a pool address (like pool.ntp.org)
at least.
This commit is contained in:
Christian Hesse 2023-06-22 14:21:52 +02:00
parent e7d9a94ad8
commit 6469825398

View file

@ -504,6 +504,7 @@
# check if system time is sync
:set IsTimeSync do={
:global IsTimeSyncCached;
:global IsTimeSyncResetNtp;
:global LogPrintExit2;
@ -516,6 +517,18 @@
:set IsTimeSyncCached true;
:return true;
}
:if ([ /system/resource/get uptime ] < 3m || $IsTimeSyncResetNtp = true) do={
:return false;
}
:set IsTimeSyncResetNtp true;
/system/ntp/client/set enabled=no;
:delay 20ms;
/system/ntp/client/set enabled=yes;
/system/scheduler/add name="clear-IsTimeSyncResetNtp" interval=1m \
on-event=("/system/scheduler/remove clear-IsTimeSyncResetNtp; " . \
":global IsTimeSyncResetNtp; :set IsTimeSyncResetNtp;");
:return false;
}