mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-27 12:30:43 +00:00
Exit the configuration file parser as soon as we are done with it.
This makes the peak memory consumption significantly lower (-15% using "sensors" in my tests). git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5644 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
15218a5e02
commit
16dbc995ec
2 files changed
+22
-10
No files matched your search
@@ -10,6 +10,7 @@ SVN-HEAD
|
||||
Skip non-file sysfs entries for speed
|
||||
Fix memory leak in scanner when using flex 2.5.9 or later
|
||||
Report configuration file read errors
|
||||
Exit the configuration file parser sooner
|
||||
lm_sensors.init: Support new format of /etc/sysconfig/lm_sensors (#2246)
|
||||
Drop support for kernels 2.4 and earlier
|
||||
lm_sensors.init.suse: Delete (actual SuSE script is much different)
|
||||
|
||||
+21
-10
@@ -61,6 +61,20 @@ static int sensors_parse(void)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int parse_config(FILE *input)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (sensors_scanner_init(input))
|
||||
return -SENSORS_ERR_PARSE;
|
||||
err = sensors_parse();
|
||||
sensors_scanner_exit();
|
||||
if (err)
|
||||
return -SENSORS_ERR_PARSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sensors_init(FILE *input)
|
||||
{
|
||||
int res;
|
||||
@@ -71,10 +85,9 @@ int sensors_init(FILE *input)
|
||||
(res = sensors_read_sysfs_chips()))
|
||||
goto exit_cleanup;
|
||||
|
||||
res = -SENSORS_ERR_PARSE;
|
||||
if (input) {
|
||||
if (sensors_scanner_init(input) ||
|
||||
sensors_parse())
|
||||
res = parse_config(input);
|
||||
if (res)
|
||||
goto exit_cleanup;
|
||||
} else {
|
||||
/* No configuration provided, use default */
|
||||
@@ -82,14 +95,14 @@ int sensors_init(FILE *input)
|
||||
if (!input && errno == ENOENT)
|
||||
input = fopen(ALT_CONFIG_FILE, "r");
|
||||
if (input) {
|
||||
if (sensors_scanner_init(input) ||
|
||||
sensors_parse()) {
|
||||
fclose(input);
|
||||
goto exit_cleanup;
|
||||
}
|
||||
res = parse_config(input);
|
||||
fclose(input);
|
||||
if (res)
|
||||
goto exit_cleanup;
|
||||
|
||||
} else if (errno != ENOENT) {
|
||||
sensors_parse_error(strerror(errno), 0);
|
||||
res = -SENSORS_ERR_PARSE;
|
||||
goto exit_cleanup;
|
||||
}
|
||||
}
|
||||
@@ -197,8 +210,6 @@ void sensors_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
sensors_scanner_exit();
|
||||
|
||||
for (i = 0; i < sensors_proc_chips_count; i++) {
|
||||
free_chip_name(&sensors_proc_chips[i].chip);
|
||||
free_chip_features(&sensors_proc_chips[i]);
|
||||
|
||||
Reference in new issue
Block a user