From 72fdd4aa7ffacbc35e9c3a225ae6e1a5afaaf5b7 Mon Sep 17 00:00:00 2001 From: Chris Kuethe Date: Sat, 4 Aug 2007 02:58:03 +0000 Subject: This diff makes ntpd poll for sensors more aggressively when the use of sensors is requested, but no sensors are found. ok henning --- usr.sbin/ntpd/ntp.c | 7 +++++-- usr.sbin/ntpd/ntpd.h | 4 ++-- usr.sbin/ntpd/sensors.c | 13 +++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 41d8f788b32..26bd5669fe3 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.98 2007/01/15 08:19:11 otto Exp $ */ +/* $OpenBSD: ntp.c,v 1.99 2007/08/04 02:58:02 ckuethe Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -253,9 +253,12 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf) if (last_sensor_scan == 0 || last_sensor_scan + SENSOR_SCAN_INTERVAL < getmonotime()) { - sensor_scan(); + sensors_cnt = sensor_scan(); last_sensor_scan = getmonotime(); } + if (!TAILQ_EMPTY(&conf->ntp_conf_sensors) && sensors_cnt == 0 && + nextaction > last_sensor_scan + SENSOR_SCAN_INTERVAL) + nextaction = last_sensor_scan + SENSOR_SCAN_INTERVAL; sensors_cnt = 0; TAILQ_FOREACH(s, &conf->ntp_sensors, entry) { if (conf->settime && s->offsets[0].offset) diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index 6f016cdc0a8..daf17772670 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.84 2007/04/30 01:33:33 deraadt Exp $ */ +/* $OpenBSD: ntpd.h,v 1.85 2007/08/04 02:58:02 ckuethe Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -308,7 +308,7 @@ struct s_fixedpt d_to_sfp(double); /* sensors.c */ void sensor_init(void); -void sensor_scan(void); +int sensor_scan(void); void sensor_query(struct ntp_sensor *); int sensor_hotplugfd(void); void sensor_hotplugevent(int); diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c index 3df6cbdb494..dde110f8f72 100644 --- a/usr.sbin/ntpd/sensors.c +++ b/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.32 2007/01/23 17:44:38 claudio Exp $ */ +/* $OpenBSD: sensors.c,v 1.33 2007/08/04 02:58:02 ckuethe Exp $ */ /* * Copyright (c) 2006 Henning Brauer @@ -45,16 +45,21 @@ sensor_init(void) TAILQ_INIT(&conf->ntp_sensors); } -void +int sensor_scan(void) { - int i; + int i, n; char d[MAXDEVNAMLEN]; struct sensor s; + n = 0; for (i = 0; i < MAXSENSORDEVICES; i++) - if (sensor_probe(i, d, &s)) + if (sensor_probe(i, d, &s)) { sensor_add(i, d); + n++; + } + + return n; } int -- cgit v1.2.3