]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Accept float value as initstepslew threshold
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 9 May 2013 17:15:25 +0000 (19:15 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 14 May 2013 15:16:41 +0000 (17:16 +0200)
acquire.c
acquire.h
conf.c

index a35a09bacb9e0b5ea6dc1c629969ca09b7b6b645..01e705c9a3a93a7ed3a72a2488d73f7164e7320f 100644 (file)
--- a/acquire.c
+++ b/acquire.c
@@ -94,7 +94,7 @@ static int n_sources;
 static int n_started_sources;
 static int n_completed_sources;
 
-static int init_slew_threshold = -1;
+static double init_slew_threshold;
 
 union sockaddr_in46 {
   struct sockaddr_in in4;
@@ -701,7 +701,7 @@ process_measurements(void)
        the system clock is fast of the reference, i.e. it needs to be
        stepped backwards. */
 
-    if (fabs(estimated_offset) > (double) init_slew_threshold) {
+    if (fabs(estimated_offset) > init_slew_threshold) {
       LOG(LOGS_INFO, LOGF_Acquire, "System's initial offset : %.6f seconds %s of true (step)",
           fabs(estimated_offset),
           (estimated_offset >= 0) ? "fast" : "slow");
@@ -753,7 +753,7 @@ start_source_timeout_handler(void *not_used)
 /* ================================================== */
 
 void
-ACQ_StartAcquisition(int n, IPAddr *ip_addrs, int threshold, void (*after_hook)(void *), void *anything)
+ACQ_StartAcquisition(int n, IPAddr *ip_addrs, double threshold, void (*after_hook)(void *), void *anything)
 {
 
   int i, ip4, ip6;
index d1b1845cf43c81d29366de4782a47615f81ca066..cd15ccec3b932321d990fd2a1489cab791874a7f 100644 (file)
--- a/acquire.h
+++ b/acquire.h
@@ -35,7 +35,7 @@ extern void ACQ_Initialise(void);
 
 extern void ACQ_Finalise(void);
 
-extern void ACQ_StartAcquisition(int n, IPAddr *ip_addrs, int init_slew_threshold,
+extern void ACQ_StartAcquisition(int n, IPAddr *ip_addrs, double init_slew_threshold,
                                  void (*after_hook)(void *), void *anything);
 
 extern void ACQ_AccumulateSample(ACQ_Source acq_source, double offset, double root_distance);
diff --git a/conf.c b/conf.c
index af5da61e01fec17ad0fa04a79ac8574f680a0f96..04e4bb45d71e203df837d3bfd6d71c6a329d979b 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -147,7 +147,7 @@ static int n_init_srcs;
 
 /* Threshold (in seconds) - if absolute value of initial error is less
    than this, slew instead of stepping */
-static int init_slew_threshold = -1;
+static double init_slew_threshold;
 #define MAX_INIT_SRCS 8
 static IPAddr init_srcs_ip[MAX_INIT_SRCS];
 
@@ -856,7 +856,6 @@ parse_initstepslew(const char *line)
   const char *p;
   char hostname[HOSTNAME_LEN+1];
   int n;
-  int threshold;
   IPAddr ip_addr;
 
   /* Ignore the line if chronyd was started with -R. */
@@ -867,7 +866,7 @@ parse_initstepslew(const char *line)
   n_init_srcs = 0;
   p = line;
 
-  if (sscanf(p, "%d%n", &threshold, &n) == 1) {
+  if (sscanf(p, "%lf%n", &init_slew_threshold, &n) == 1) {
     p += n;
   } else {
     LOG(LOGS_WARN, LOGF_Configure, "Could not parse initstepslew threshold at line %d", line_number);
@@ -892,7 +891,6 @@ parse_initstepslew(const char *line)
   }
   if (n_init_srcs > 0) {
     do_init_stepslew = 1;
-    init_slew_threshold = threshold;
   } else {
     LOG(LOGS_WARN, LOGF_Configure, "No usable initstepslew servers at line %d\n", line_number);
   }