diff --git a/chrony.texi b/chrony.texi index 7fd63ee..94e8323 100644 --- a/chrony.texi +++ b/chrony.texi @@ -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 diff --git a/chronyd.8 b/chronyd.8 index e271d4c..b837831 100644 --- 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 3b691f1..6136cb7 100644 --- 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 15d24d7..cbe15ed 100644 --- 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 e79a44d..6968ded 100644 --- 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