diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-05-28 18:47:26 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-05-28 18:47:26 +0000 |
commit | ee271e2904f4aa32ea2ecaafc166fdf57d72cb34 (patch) | |
tree | 9c4d48ead059640978c87b32168b4ce64e35f357 /usr.sbin | |
parent | 6c3a3119902ab4d8b8ee50c346f7595059b22fe8 (diff) |
let sensor_query handle removals itself
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 5 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/ntpd/sensors.c | 23 |
3 files changed, 16 insertions, 17 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 7592c210aff..3d1c0c6a417 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.75 2006/05/28 03:23:08 henning Exp $ */ +/* $OpenBSD: ntp.c,v 1.76 2006/05/28 18:47:25 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -297,8 +297,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf) for (s = TAILQ_FIRST(&conf->ntp_sensors); s != NULL; s = next_s) { next_s = TAILQ_NEXT(s, entry); - if (sensor_query(s) == -1) - sensor_remove(s); + sensor_query(s); } } diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h index cf550cecb69..3e5341191eb 100644 --- a/usr.sbin/ntpd/ntpd.h +++ b/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.67 2006/05/27 22:22:47 henning Exp $ */ +/* $OpenBSD: ntpd.h,v 1.68 2006/05/28 18:47:25 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -283,7 +283,6 @@ struct s_fixedpt d_to_sfp(double); /* sensors.c */ void sensor_init(struct ntpd_conf *); void sensor_scan(void); -void sensor_remove(struct ntp_sensor *); -int sensor_query(struct ntp_sensor *); +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 a8823f367af..e3b19e15ce7 100644 --- a/usr.sbin/ntpd/sensors.c +++ b/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.11 2006/05/28 16:41:40 henning Exp $ */ +/* $OpenBSD: sensors.c,v 1.12 2006/05/28 18:47:25 henning Exp $ */ /* * Copyright (c) 2006 Henning Brauer <henning@openbsd.org> @@ -34,8 +34,9 @@ #define SENSORS_MAX 255 #define _PATH_DEV_HOTPLUG "/dev/hotplug" -void sensor_probe(int); -void sensor_add(struct sensor *); +void sensor_probe(int); +void sensor_add(struct sensor *); +void sensor_remove(struct ntp_sensor *); struct ntpd_conf *conf; @@ -117,7 +118,7 @@ sensor_remove(struct ntp_sensor *s) free(s); } -int +void sensor_query(struct ntp_sensor *s) { struct sensor sensor; @@ -134,19 +135,21 @@ sensor_query(struct ntp_sensor *s) len = sizeof(sensor); if (sysctl(mib, 3, &sensor, &len, NULL, 0) == -1) { log_warn("sensor_query sysctl"); - return (0); + return; } if (sensor.flags & SENSOR_FINVALID || sensor.status != SENSOR_S_OK) - return (0); + return; if (sensor.type != SENSOR_TIMEDELTA || - strcmp(sensor.device, s->device)) - return (-1); /* causes sensor removal */ + strcmp(sensor.device, s->device)) { + sensor_remove(s); + return; + } if (sensor.tv.tv_sec == s->update.rcvd) /* already seen */ - return (0); + return; s->update.offset = 0 - (float)sensor.value / 1000000000.0; s->update.status.stratum = 0; /* increased when sent out */ @@ -160,8 +163,6 @@ sensor_query(struct ntp_sensor *s) s->update.good = 1; log_debug("sensor %s: offset %f", s->device, s->update.offset); - - return (0); } int |