Add option to ignore initstepslew and makestep directives
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.
This commit is contained in:
parent
4933c216b2
commit
f2eb6b165a
5 changed files with 37 additions and 1 deletions
|
@ -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
|
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
|
this is not the case, e.g. Solaris and SunOS the option should not be
|
||||||
used.
|
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
|
@item -s
|
||||||
This option will set the system clock from the computer's real-time
|
This option will set the system clock from the computer's real-time
|
||||||
clock. This is analogous to supplying the `-s' flag to the
|
clock. This is analogous to supplying the `-s' flag to the
|
||||||
|
|
|
@ -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
|
On systems where this is not the case, e.g. Solaris and SunOS the option
|
||||||
should not be used.
|
should not be used.
|
||||||
.TP
|
.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
|
.B \-s
|
||||||
This option will set the system clock from the computer's real-time
|
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
|
clock. This is analogous to supplying the \fI-s\fR flag to the
|
||||||
|
|
19
conf.c
19
conf.c
|
@ -117,6 +117,7 @@ static void parse_leapsectz(const char *);
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Configuration variables */
|
/* Configuration variables */
|
||||||
|
|
||||||
|
static int restarted = 0;
|
||||||
static char *rtc_device = "/dev/rtc";
|
static char *rtc_device = "/dev/rtc";
|
||||||
static int acquisition_port = 0; /* 0 means let kernel choose port */
|
static int acquisition_port = 0; /* 0 means let kernel choose port */
|
||||||
static int ntp_port = 123;
|
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 */
|
/* Read the configuration file */
|
||||||
void
|
void
|
||||||
CNF_ReadFile(const char *filename)
|
CNF_ReadFile(const char *filename)
|
||||||
|
@ -853,6 +862,11 @@ parse_initstepslew(const char *line)
|
||||||
int threshold;
|
int threshold;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
|
|
||||||
|
/* Ignore the line if chronyd was started with -R. */
|
||||||
|
if (restarted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
n_init_srcs = 0;
|
n_init_srcs = 0;
|
||||||
p = line;
|
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",
|
"Could not read threshold or update limit for stepping clock at line %d\n",
|
||||||
line_number);
|
line_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disable limited makestep if chronyd was started with -R. */
|
||||||
|
if (restarted && make_step_limit > 0) {
|
||||||
|
make_step_limit = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
2
conf.h
2
conf.h
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include "addressing.h"
|
#include "addressing.h"
|
||||||
|
|
||||||
|
extern void CNF_SetRestarted(int);
|
||||||
|
|
||||||
extern char *CNF_GetRtcDevice(void);
|
extern char *CNF_GetRtcDevice(void);
|
||||||
|
|
||||||
extern void CNF_ReadFile(const char *filename);
|
extern void CNF_ReadFile(const char *filename);
|
||||||
|
|
5
main.c
5
main.c
|
@ -287,7 +287,7 @@ int main
|
||||||
char *conf_file = NULL;
|
char *conf_file = NULL;
|
||||||
char *user = NULL;
|
char *user = NULL;
|
||||||
int debug = 0, nofork = 0;
|
int debug = 0, nofork = 0;
|
||||||
int do_init_rtc = 0;
|
int do_init_rtc = 0, restarted = 0;
|
||||||
int other_pid;
|
int other_pid;
|
||||||
int lock_memory = 0, sched_priority = 0;
|
int lock_memory = 0, sched_priority = 0;
|
||||||
|
|
||||||
|
@ -308,6 +308,8 @@ int main
|
||||||
lock_memory = 1;
|
lock_memory = 1;
|
||||||
} else if (!strcmp("-r", *argv)) {
|
} else if (!strcmp("-r", *argv)) {
|
||||||
reload = 1;
|
reload = 1;
|
||||||
|
} else if (!strcmp("-R", *argv)) {
|
||||||
|
restarted = 1;
|
||||||
} else if (!strcmp("-u", *argv)) {
|
} else if (!strcmp("-u", *argv)) {
|
||||||
++argv, --argc;
|
++argv, --argc;
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
|
@ -352,6 +354,7 @@ int main
|
||||||
|
|
||||||
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
|
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
|
||||||
|
|
||||||
|
CNF_SetRestarted(restarted);
|
||||||
CNF_ReadFile(conf_file);
|
CNF_ReadFile(conf_file);
|
||||||
|
|
||||||
/* Check whether another chronyd may already be running. Do this after
|
/* Check whether another chronyd may already be running. Do this after
|
||||||
|
|
Loading…
Reference in a new issue