From 64698253983f4ea608b31eb46fb4ac11fc9a156c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 22 Jun 2023 14:21:52 +0200 Subject: 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. --- global-functions.rsc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 98f6978..bdab5a2 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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; } -- cgit v1.2.3-54-g00ecf