]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: ignore saved remote poll when peer is not responding
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 14 Jul 2017 10:43:26 +0000 (12:43 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 14 Jul 2017 18:06:31 +0000 (20:06 +0200)
When a peer stops responding, allow our actual polling interval to be
longer than poll saved from the last valid response.

ntp_core.c

index f916fffafca6b280acf43a142bf1c17ababe337b..35ef9f3b5ff7001959741f1eac106f4fc782c6c6 100644 (file)
@@ -260,6 +260,9 @@ static ARR_Instance broadcasts;
 /* Maximum poll interval set by KoD RATE */
 #define MAX_KOD_RATE_POLL SRC_DEFAULT_MAXPOLL
 
+/* Maximum number of missed responses to follow peer's polling interval */
+#define MAX_PEER_POLL_TX 8
+
 /* Invalid socket, different from the one in ntp_io.c */
 #define INVALID_SOCK_FD -2
 
@@ -781,10 +784,8 @@ get_transmit_delay(NCR_Instance inst, int on_tx, double last_tx)
           /* Use shorter of the local and remote poll interval, but not shorter
              than the allowed minimum */
           poll_to_use = inst->local_poll;
-          if (poll_to_use > inst->remote_poll)
-            poll_to_use = inst->remote_poll;
-          if (poll_to_use < inst->minpoll)
-            poll_to_use = inst->minpoll;
+          if (poll_to_use > inst->remote_poll && inst->tx_count < MAX_PEER_POLL_TX)
+            poll_to_use = MAX(inst->remote_poll, inst->minpoll);
 
           delay_time = UTI_Log2ToDouble(poll_to_use);