]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add option to ignore initstepslew and makestep directives
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 26 Apr 2013 14:27:15 +0000 (16:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 26 Apr 2013 15:38:37 +0000 (17:38 +0200)
When chronyd is started with -R, the initstepslew directive and the
makestep directive with a positive limit will be ignored. This is useful
when restarting chronyd to avoid unnecessary clock adjustments. It can
be used with -r.

chrony.texi
chronyd.8
conf.c
conf.h
main.c

index 7fd63eed13f70368a3840c3dd8cfd0ebe5e6d2ce..94e8323a8ebec6ca09e9e43286ce628bfe66e4e5 100644 (file)
@@ -1067,6 +1067,12 @@ maintain clock compensation whilst not under @code{chronyd's} control.
 The only version where this happens so far is Linux.  On systems where
 this is not the case, e.g. Solaris and SunOS the option should not be
 used.
+@item -R
+When this option is used, the @code{initstepslew} directive and the
+@code{makestep} directive used with a positive limit will be ignored.
+This option is useful when restarting @code{chronyd} and can be used
+in conjuction with the `-r' option.
+
 @item -s
 This option will set the system clock from the computer's real-time
 clock.  This is analogous to supplying the `-s' flag to the
index e271d4ccbed5fbc9c572110558545b6197b641c9..b837831b1e0426f86883ac25d1e31c5756068731 100644 (file)
--- a/chronyd.8
+++ b/chronyd.8
@@ -69,6 +69,12 @@ systems where the kernel can maintain clock compensation whilst not under
 On systems where this is not the case, e.g. Solaris and SunOS the option
 should not be used.
 .TP
+.B \-R
+When this option is used, the \fIinitstepslew\fR directive and the
+\fImakestep\fR directive used with a positive limit will be ignored. This
+option is useful when restarting \fBchronyd\fR and can be used in conjuction
+with the \fB-r\fR option.
+.TP
 .B \-s
 This option will set the system clock from the computer's real-time
 clock.  This is analogous to supplying the \fI-s\fR flag to the
diff --git a/conf.c b/conf.c
index 3b691f1a365309bd4844a8ba31abb5d8d3bd3eba..6136cb7c25a01b8d9dae21c3da3dc40fcc5c0c08 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -117,6 +117,7 @@ static void parse_leapsectz(const char *);
 /* ================================================== */
 /* Configuration variables */
 
+static int restarted = 0;
 static char *rtc_device = "/dev/rtc";
 static int acquisition_port = 0; /* 0 means let kernel choose port */
 static int ntp_port = 123;
@@ -325,6 +326,14 @@ static AllowDeny cmd_auth_list = {&cmd_auth_list, &cmd_auth_list};
 
 /* ================================================== */
 
+void
+CNF_SetRestarted(int r)
+{
+  restarted = r;
+}
+
+/* ================================================== */
+
 /* Read the configuration file */
 void
 CNF_ReadFile(const char *filename)
@@ -853,6 +862,11 @@ parse_initstepslew(const char *line)
   int threshold;
   IPAddr ip_addr;
 
+  /* Ignore the line if chronyd was started with -R. */
+  if (restarted) {
+    return;
+  }
+
   n_init_srcs = 0;
   p = line;
 
@@ -955,6 +969,11 @@ parse_makestep(const char *line)
         "Could not read threshold or update limit for stepping clock at line %d\n",
         line_number);
   }
+
+  /* Disable limited makestep if chronyd was started with -R. */
+  if (restarted && make_step_limit > 0) {
+    make_step_limit = 0;
+  }
 }
 
 /* ================================================== */
diff --git a/conf.h b/conf.h
index 15d24d7613133f4ce80c72e095b455d9e96dc093..cbe15ed2ab1d2fccbf96af18c18102280c8c4bf4 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -29,6 +29,8 @@
 
 #include "addressing.h"
 
+extern void CNF_SetRestarted(int);
+
 extern char *CNF_GetRtcDevice(void);
 
 extern void CNF_ReadFile(const char *filename);
diff --git a/main.c b/main.c
index e79a44d10d9a647cfe055507f7d3e77cbad38f24..6968ded209012a2bd2fed2787119b0fe6401d33f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -287,7 +287,7 @@ int main
   char *conf_file = NULL;
   char *user = NULL;
   int debug = 0, nofork = 0;
-  int do_init_rtc = 0;
+  int do_init_rtc = 0, restarted = 0;
   int other_pid;
   int lock_memory = 0, sched_priority = 0;
 
@@ -308,6 +308,8 @@ int main
       lock_memory = 1;
     } else if (!strcmp("-r", *argv)) {
       reload = 1;
+    } else if (!strcmp("-R", *argv)) {
+      restarted = 1;
     } else if (!strcmp("-u", *argv)) {
       ++argv, --argc;
       if (argc == 0) {
@@ -352,6 +354,7 @@ int main
   
   LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
 
+  CNF_SetRestarted(restarted);
   CNF_ReadFile(conf_file);
 
   /* Check whether another chronyd may already be running.  Do this after