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:
Miroslav Lichvar
2013-04-26 16:27:15 +02:00
parent 4933c216b2
commit f2eb6b165a
5 changed files with 37 additions and 1 deletions

19
conf.c
View File

@@ -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;
}
}
/* ================================================== */