summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2006-06-01 04:42:24 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2006-06-01 04:42:24 +0000
commit94569be7ba92741db312e075ae3c63347230e0d0 (patch)
treeb818b5d1384b223e4ae0b5d669862b23afd36453 /usr.sbin/ntpd
parente33ddfe865dee31acc835d7b9f6f9c8593b5fc5c (diff)
put back regular sensors scanning
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/ntp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index 3d39563770b..2a9abed46ae 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.78 2006/05/31 01:27:21 henning Exp $ */
+/* $OpenBSD: ntp.c,v 1.79 2006/06/01 04:42:23 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -78,7 +78,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
struct ntp_sensor *s, *next_s;
struct timespec tp;
struct stat stb;
- time_t nextaction;
+ time_t nextaction, last_sensor_scan = 0;
void *newp;
switch (pid = fork()) {
@@ -152,7 +152,6 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
conf->scale = 1;
sensor_init(conf);
- sensor_scan();
log_info("ntp engine ready");
@@ -237,6 +236,10 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
}
+ if (last_sensor_scan + SENSOR_SCAN_INTERVAL < time(NULL)) {
+ sensor_scan();
+ last_sensor_scan = time(NULL);
+ }
sensors_cnt = 0;
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
sensors_cnt++;
@@ -426,18 +429,27 @@ priv_adjtime(void)
int offset_cnt = 0, i = 0, j;
struct ntp_offset **offsets;
double offset_median;
+ u_int8_t priority = 0;
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER)
continue;
if (!p->update.good)
return;
+ if (p->priority > priority) {
+ priority = p->priority;
+ offset_cnt = 0;
+ }
offset_cnt += p->weight;
}
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
+ if (s->priority > priority) {
+ priority = s->priority;
+ offset_cnt = 0;
+ }
offset_cnt += p->weight;
}
@@ -447,6 +459,8 @@ priv_adjtime(void)
TAILQ_FOREACH(p, &conf->ntp_peers, entry) {
if (p->trustlevel < TRUSTLEVEL_BADPEER)
continue;
+ if (p->priority < priority)
+ continue;
for (j = 0; j < p->weight; j++)
offsets[i++] = &p->update;
}
@@ -454,6 +468,8 @@ priv_adjtime(void)
TAILQ_FOREACH(s, &conf->ntp_sensors, entry) {
if (!s->update.good)
continue;
+ if (s->priority < priority)
+ continue;
for (j = 0; j < s->weight; j++)
offsets[i++] = &s->update;
}