]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Stop burst sampling when received KoD RATE
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 19 Apr 2010 13:10:25 +0000 (15:10 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Apr 2010 12:35:27 +0000 (14:35 +0200)
ntp_core.c

index 866d120dcd8eb854030f1aa167ec91734474d50e..7ca8dc11d4c73b65c19f687c57a906b30d326add 100644 (file)
@@ -1110,6 +1110,24 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
 
   }
 
+  /* Reduce polling rate if KoD RATE was received */
+  if (kod_rate && valid_kod) {
+    if (inst->remote_poll > inst->minpoll) {
+      inst->minpoll = inst->remote_poll;
+      if (inst->minpoll > inst->maxpoll)
+        inst->maxpoll = inst->minpoll;
+      if (inst->minpoll > inst->local_poll)
+        inst->local_poll = inst->minpoll;
+      LOG(LOGS_WARN, LOGF_NtpCore, "Received KoD RATE from %s, minpoll set to %d", UTI_IPToString(&inst->remote_addr.ip_addr), inst->minpoll);
+    }
+
+    /* Stop ongoing burst */
+    if (inst->opmode == MD_BURST_WAS_OFFLINE || inst->opmode == MD_BURST_WAS_ONLINE) {
+      inst->burst_good_samples_to_go = 0;
+      LOG(LOGS_WARN, LOGF_NtpCore, "Received KoD RATE from %s, burst sampling stopped", UTI_IPToString(&inst->remote_addr.ip_addr), inst->minpoll);
+    }
+  }
+
   /* If we're in burst mode, check whether the burst is completed and
      revert to the previous mode */
 
@@ -1212,16 +1230,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
 
   }
 
-  /* Reduce polling if KoD RATE was received */
   if (kod_rate && valid_kod) {
-    if (inst->remote_poll > inst->minpoll) {
-      inst->minpoll = inst->remote_poll;
-      if (inst->minpoll > inst->maxpoll)
-        inst->maxpoll = inst->minpoll;
-      if (inst->minpoll > inst->local_poll)
-        inst->local_poll = inst->minpoll;
-      LOG(LOGS_INFO, LOGF_NtpCore, "Received KoD RATE from %s, minpoll set to %d", UTI_IPToString(&inst->remote_addr.ip_addr), inst->minpoll);
-    }
     /* Back off for a while */
     delay_time += (double) (4 * (1UL << inst->minpoll));
   }