]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: allow sub-second maxpoll
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 Jun 2018 15:37:31 +0000 (17:37 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 22 Jun 2018 10:12:11 +0000 (12:12 +0200)
Remove the maxpoll-specific limit and allow both minpoll and maxpoll to
be set to a negative value.

ntp_core.c

index fa2f762c9728e42196eed6ae62aa224deae9aac1..cebaa20ca34c474b9bde627d8f1c5e80442f61c1 100644 (file)
@@ -264,8 +264,7 @@ static ARR_Instance broadcasts;
 #define MAX_MAXDELAYDEVRATIO 1.0e6
 
 /* Minimum and maximum allowed poll interval */
-#define MIN_MINPOLL -4
-#define MIN_MAXPOLL 0
+#define MIN_POLL -4
 #define MAX_POLL 24
 
 /* Enable sub-second polling intervals only when the peer delay is not
@@ -540,12 +539,13 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar
   result->interleaved = params->interleaved;
 
   result->minpoll = params->minpoll;
-  if (result->minpoll < MIN_MINPOLL)
+  if (result->minpoll < MIN_POLL)
     result->minpoll = SRC_DEFAULT_MINPOLL;
   else if (result->minpoll > MAX_POLL)
     result->minpoll = MAX_POLL;
+
   result->maxpoll = params->maxpoll;
-  if (result->maxpoll < MIN_MAXPOLL)
+  if (result->maxpoll < MIN_POLL)
     result->maxpoll = SRC_DEFAULT_MAXPOLL;
   else if (result->maxpoll > MAX_POLL)
     result->maxpoll = MAX_POLL;
@@ -2349,7 +2349,7 @@ NCR_SetConnectivity(NCR_Instance inst, SRC_Connectivity connectivity)
 void
 NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll)
 {
-  if (new_minpoll < MIN_MINPOLL || new_minpoll > MAX_POLL)
+  if (new_minpoll < MIN_POLL || new_minpoll > MAX_POLL)
     return;
   inst->minpoll = new_minpoll;
   LOG(LOGS_INFO, "Source %s new minpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_minpoll);
@@ -2362,7 +2362,7 @@ NCR_ModifyMinpoll(NCR_Instance inst, int new_minpoll)
 void
 NCR_ModifyMaxpoll(NCR_Instance inst, int new_maxpoll)
 {
-  if (new_maxpoll < MIN_MAXPOLL || new_maxpoll > MAX_POLL)
+  if (new_maxpoll < MIN_POLL || new_maxpoll > MAX_POLL)
     return;
   inst->maxpoll = new_maxpoll;
   LOG(LOGS_INFO, "Source %s new maxpoll %d", UTI_IPToString(&inst->remote_addr.ip_addr), new_maxpoll);