]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: don't reset polling interval when switching to/from online
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 23 Nov 2016 11:45:11 +0000 (12:45 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 Nov 2016 16:33:42 +0000 (17:33 +0100)
This allows chronyd to ramp up the polling interval even when the source
is frequently switched between the online and offline modes.

ntp_core.c
ntp_core.h
ntp_sources.c

index e2344991773fd50deccea503ebe8e0e561a7eb17..b41affb2d4a6aa2bb0eec98ccade8be61920ef07 100644 (file)
@@ -553,6 +553,7 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar
   result->tx_suspended = 1;
   result->opmode = params->online ? MD_ONLINE : MD_OFFLINE;
   result->local_poll = result->minpoll;
+  result->poll_score = 0.0;
   UTI_ZeroTimespec(&result->local_tx.ts);
   result->local_tx.err = 0.0;
   result->local_tx.source = NTP_TS_DAEMON;
@@ -605,7 +606,6 @@ NCR_ResetInstance(NCR_Instance instance)
   instance->tx_count = 0;
   instance->presend_done = 0;
 
-  instance->poll_score = 0.0;
   instance->remote_poll = 0;
   instance->remote_stratum = 0;
 
@@ -619,7 +619,13 @@ NCR_ResetInstance(NCR_Instance instance)
   UTI_ZeroTimespec(&instance->local_rx.ts);
   instance->local_rx.err = 0.0;
   instance->local_rx.source = NTP_TS_DAEMON;
+}
+
+/* ================================================== */
 
+void
+NCR_ResetPoll(NCR_Instance instance)
+{
   if (instance->local_poll != instance->minpoll) {
     instance->local_poll = instance->minpoll;
 
@@ -634,9 +640,8 @@ NCR_ResetInstance(NCR_Instance instance)
 void
 NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr)
 {
+  NCR_ResetInstance(inst);
   inst->remote_addr = *remote_addr;
-  inst->tx_count = 0;
-  inst->presend_done = 0;
 
   if (inst->mode == MODE_CLIENT)
     close_client_socket(inst);
index 4d0c214ee2877e907c552f975aef70085d8b8180..699cb835490e2ac9f01467f55b2b24d0fe454aaf 100644 (file)
@@ -70,6 +70,9 @@ extern void NCR_StartInstance(NCR_Instance instance);
 /* Reset an instance */
 extern void NCR_ResetInstance(NCR_Instance inst);
 
+/* Reset polling interval of an instance */
+extern void NCR_ResetPoll(NCR_Instance instance);
+
 /* Change the remote address of an instance */
 extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr);
 
index 00f922bb96f3bf1994efaf7a568a827b8c4632ce..835599fe503f53004d61ea76e662da5fdc42f9b1 100644 (file)
@@ -851,6 +851,7 @@ slew_sources(struct timespec *raw,
     if (record->remote_addr) {
       if (change_type == LCL_ChangeUnknownStep) {
         NCR_ResetInstance(record->data);
+        NCR_ResetPoll(record->data);
       } else {
         NCR_SlewTimes(record->data, cooked, dfreq, doffset);
       }