Browse Source

stop passing the config around all time, just store one copy

OPENBSD_4_0
henning 18 years ago
parent
commit
d3875817fc
3 changed files with 19 additions and 16 deletions
  1. +3
    -3
      src/usr.sbin/ntpd/ntp.c
  2. +3
    -3
      src/usr.sbin/ntpd/ntpd.h
  3. +13
    -10
      src/usr.sbin/ntpd/sensors.c

+ 3
- 3
src/usr.sbin/ntpd/ntp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntp.c,v 1.73 2006/05/27 21:27:34 henning Exp $ */
/* $OpenBSD: ntp.c,v 1.74 2006/05/27 22:22:47 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -237,7 +237,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
}
if (last_sensor_scan + SENSOR_SCAN_INTERVAL < time(NULL)) {
sensor_scan(conf);
sensor_scan();
last_sensor_scan = time(NULL);
}
sensors_cnt = 0;
@ -301,7 +301,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
s = next_s) {
next_s = TAILQ_NEXT(s, entry);
if (sensor_query(s) == -1)
sensor_remove(conf, s);
sensor_remove(s);
}
}


+ 3
- 3
src/usr.sbin/ntpd/ntpd.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.66 2006/05/27 21:27:34 henning Exp $ */
/* $OpenBSD: ntpd.h,v 1.67 2006/05/27 22:22:47 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -282,8 +282,8 @@ struct s_fixedpt d_to_sfp(double);
/* sensors.c */
void sensor_init(struct ntpd_conf *);
void sensor_scan(struct ntpd_conf *);
void sensor_remove(struct ntpd_conf *, struct ntp_sensor *);
void sensor_scan(void);
void sensor_remove(struct ntp_sensor *);
int sensor_query(struct ntp_sensor *);
int sensor_hotplugfd(void);
void sensor_hotplugevent(int);

+ 13
- 10
src/usr.sbin/ntpd/sensors.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: sensors.c,v 1.4 2006/05/27 21:33:47 henning Exp $ */
/* $OpenBSD: sensors.c,v 1.5 2006/05/27 22:22:47 henning Exp $ */
/*
* Copyright (c) 2006 Henning Brauer <henning@openbsd.org>
@ -34,26 +34,29 @@
#define SENSORS_MAX 255
#define _PATH_DEV_HOTPLUG "/dev/hotplug"
void sensor_probe(struct ntpd_conf *, int);
void sensor_add(struct ntpd_conf *, struct sensor *);
void sensor_probe(int);
void sensor_add(struct sensor *);
struct ntpd_conf *conf;
void
sensor_init(struct ntpd_conf *conf)
sensor_init(struct ntpd_conf *c)
{
conf = c;
TAILQ_INIT(&conf->ntp_sensors);
}
void
sensor_scan(struct ntpd_conf *conf)
sensor_scan(void)
{
int i;
for (i = 0; i < SENSORS_MAX; i++)
sensor_probe(conf, i);
sensor_probe(i);
}
void
sensor_probe(struct ntpd_conf *conf, int id)
sensor_probe(int id)
{
int mib[3];
size_t len;
@ -71,11 +74,11 @@ sensor_probe(struct ntpd_conf *conf, int id)
}
if (sensor.type == SENSOR_TIMEDELTA)
sensor_add(conf, &sensor);
sensor_add(&sensor);
}
void
sensor_add(struct ntpd_conf *conf, struct sensor *sensor)
sensor_add(struct sensor *sensor)
{
struct ntp_sensor *s;
struct ntp_conf_sensor *cs;
@ -107,7 +110,7 @@ sensor_add(struct ntpd_conf *conf, struct sensor *sensor)
}
void
sensor_remove(struct ntpd_conf *conf, struct ntp_sensor *s)
sensor_remove(struct ntp_sensor *s)
{
TAILQ_REMOVE(&conf->ntp_sensors, s, entry);
free(s->device);


Loading…
Cancel
Save