From 12655c1d85ea77bd2b453a71706df7fe9eed4475 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Aug 2007 17:04:12 +0000 Subject: [PATCH] Drop support for reloading the configuration with sensors_init(). Instead, the application will have to call sensors_exit() explicitly before calling sensors_init() again. Most applications don't offer any way to reload the configuration file, so better optimize for the initial load. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4693 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/init.c | 2 +- lib/libsensors.3 | 5 ++++- lib/sensors.h | 8 +++++--- prog/sensord/lib.c | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/init.c b/lib/init.c index a9203558..13c26f8e 100644 --- a/lib/init.c +++ b/lib/init.c @@ -40,7 +40,7 @@ static void free_expr(sensors_expr *expr); int sensors_init(FILE *input) { int res; - sensors_cleanup(); + if (!sensors_init_sysfs()) return -SENSORS_ERR_PROC; if ((res = sensors_read_sysfs_bus()) || (res = sensors_read_sysfs_chips())) diff --git a/lib/libsensors.3 b/lib/libsensors.3 index db176fc5..67099e5d 100644 --- a/lib/libsensors.3 +++ b/lib/libsensors.3 @@ -53,7 +53,10 @@ libsensors \- publicly accessible functions provided by the sensors library .SH DESCRIPTION .B int sensors_init(FILE *input); .br -(Re)load the configuration file and the detected chips list. If this returns a value unequal to zero, you are in trouble; you can not assume anything will be initialized properly. +Load the configuration file and the detected chips list. If this returns a +value unequal to zero, you are in trouble; you can not assume anything will +be initialized properly. If you want to reload the configuration file, call +sensors_cleanup() below before calling sensors_init() again. .B void sensors_cleanup(void); .br diff --git a/lib/sensors.h b/lib/sensors.h index f44c9430..b8336fe9 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -56,9 +56,11 @@ typedef struct sensors_chip_name { char *path; } sensors_chip_name; -/* (Re)load the configuration file and the detected chips list. If this - returns a value unequal to zero, you are in trouble; you can not - assume anything will be initialized properly. */ +/* Load the configuration file and the detected chips list. If this + returns a value unequal to zero, you are in trouble; you can not + assume anything will be initialized properly. If you want to + reload the configuration file, call sensors_cleanup() below before + calling sensors_init() again. */ int sensors_init(FILE *input); /* Clean-up function: You can't access anything after diff --git a/prog/sensord/lib.c b/prog/sensord/lib.c index 15ad4c54..a3b2b0ac 100644 --- a/prog/sensord/lib.c +++ b/prog/sensord/lib.c @@ -90,8 +90,10 @@ loadConfig sensorLog (LOG_ERR, "Error stating sensors configuration file: %s", cfgPath); ret = 10; } else if (!reload || (difftime (stats.st_mtime, cfgLastModified) > 0.0)) { - if (reload) + if (reload) { sensorLog (LOG_INFO, "configuration reloading"); + sensors_cleanup (); + } if (!(cfg = fopen (cfgPath, "r"))) { sensorLog (LOG_ERR, "Error opening sensors configuration file: %s", cfgPath); ret = 11;