]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesync: increase retry interval more slowly 16624/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Jul 2020 13:15:11 +0000 (15:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Jul 2020 13:15:11 +0000 (15:15 +0200)
The new retry intervals are [15, 20, 26, 34, 45, 60, 80, 106, 141, 188, 250,
333, 360, ...]. This should allow graceful response if a transient network
failure is encountered. Growth is exponential, but with a small power and
capped to a non-too-large value so that we resynchronize within a few minutes
after network is restored. I made the minimum 15 s to make sure that we never
send packets more often than that.

Fixes #16492.

src/timesync/timesyncd-manager.c
src/timesync/timesyncd-manager.h

index dadf213a809ff741fe18eb05031c09d55be3ed83..5570408fa14f5127a37974f7c1604d84af2df16f 100644 (file)
@@ -137,11 +137,10 @@ static int manager_send_request(Manager *m) {
         }
 
         /* re-arm timer with increasing timeout, in case the packets never arrive back */
-        if (m->retry_interval > 0) {
-                if (m->retry_interval < m->poll_interval_max_usec)
-                        m->retry_interval *= 2;
-        } else
-                m->retry_interval = m->poll_interval_min_usec;
+        if (m->retry_interval == 0)
+                m->retry_interval = NTP_RETRY_INTERVAL_MIN_USEC;
+        else
+                m->retry_interval = MIN(m->retry_interval * 4/3, NTP_RETRY_INTERVAL_MAX_USEC);
 
         r = manager_arm_timer(m, m->retry_interval);
         if (r < 0)
index 97c4e2ff34d90f65b0b2e1392311151bdd491cea..d74521c9cf59a64abeca0031bb12c20979eed71b 100644 (file)
@@ -24,6 +24,9 @@ typedef struct Manager Manager;
 #define NTP_POLL_INTERVAL_MIN_USEC      (32 * USEC_PER_SEC)
 #define NTP_POLL_INTERVAL_MAX_USEC      (2048 * USEC_PER_SEC)
 
+#define NTP_RETRY_INTERVAL_MIN_USEC     (15 * USEC_PER_SEC)
+#define NTP_RETRY_INTERVAL_MAX_USEC     (6 * 60 * USEC_PER_SEC) /* 6 minutes */
+
 struct Manager {
         sd_bus *bus;
         sd_event *event;