From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] sensord exits on any error
Date: Sun, 14 Dec 2008 15:44:29 +0000 [thread overview]
Message-ID: <20081214164429.3972b6fe@hyperion.delvare> (raw)
In-Reply-To: <alpine.DEB.2.00.0812051215080.9967@andydesk.realbig.com>
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
Hi Andy,
On Fri, 12 Dec 2008 15:45:35 -0600 (CST), Andy Poling wrote:
> It is kind of embarrassingly simple. I hope a unified diff is acceptable.
A unified diff is perfect. However I do not think the fix is as simple
as you suggested. The original code has a rather fragile way to handle
sleep times between actions, and now that failures no longer break the
loop, odd things can happen. In particular, with your patch, I hit a
case where the system log would get filled at a very high rate on
permanent errors, presumably because sleep() was called with negative
values.
Please see my attached patch which hopefully fixes all the issues. It
worked fine for me. Main differences with your original patch:
* Errors on reloadLib() are logged.
* Errors are logged using sensorLog() instead of syslog().
* Error messages use %d instead of %m. %m read errno but the sensord
code doesn't set errno.
* Each of the 3 actions are handled separately, even if one fails, the
other ones are attempted.
Please give it a try and report.
Thanks,
--
Jean Delvare
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sensord-survive-transient-errors.patch --]
[-- Type: text/x-patch; name=sensord-survive-transient-errors.patch, Size: 1967 bytes --]
Index: prog/sensord/sensord.c
===================================================================
--- prog/sensord/sensord.c (révision 5564)
+++ prog/sensord/sensord.c (copie de travail)
@@ -85,27 +85,30 @@
sensorLog (LOG_INFO, "sensord started");
- while (!done && (ret == 0)) {
- if (ret == 0)
- ret = reloadLib ();
- if ((ret == 0) && scanTime) { /* should I scan on the read cycle? */
- ret = scanChips ();
- if (scanValue <= 0)
- scanValue += scanTime;
+ while (!done) {
+ ret = reloadLib ();
+ if (ret)
+ sensorLog (LOG_NOTICE, "config reload error (%d)", ret);
+ if (scanTime && (scanValue <= 0)) {
+ if ((ret = scanChips ()))
+ sensorLog (LOG_NOTICE, "sensor scan error (%d)", ret);
+ scanValue += scanTime;
}
- if ((ret == 0) && logTime && (logValue <= 0)) {
- ret = readChips ();
+ if (logTime && (logValue <= 0)) {
+ if ((ret = readChips ()))
+ sensorLog (LOG_NOTICE, "sensor read error (%d)", ret);
logValue += logTime;
}
- if ((ret == 0) && rrdTime && rrdFile && (rrdValue <= 0)) {
- ret = rrdUpdate ();
+ if (rrdTime && rrdFile && (rrdValue <= 0)) {
+ if ((ret = rrdUpdate ()))
+ sensorLog (LOG_NOTICE, "rrd update error (%d)", ret);
/*
* The amount of time to wait is computed using the same method as
* in RRD instead of simply adding the interval.
*/
rrdValue = rrdTime - time(NULL) % rrdTime;
}
- if (!done && (ret == 0)) {
+ if (!done) {
int a = logTime ? logValue : INT_MAX;
int b = scanTime ? scanValue : INT_MAX;
int c = (rrdTime && rrdFile) ? rrdValue : INT_MAX;
@@ -117,10 +120,7 @@
}
}
- if (ret)
- sensorLog (LOG_INFO, "sensord failed (%d)", ret);
- else
- sensorLog (LOG_INFO, "sensord stopped");
+ sensorLog (LOG_INFO, "sensord stopped");
return ret;
}
[-- Attachment #3: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2008-12-14 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-05 18:34 [lm-sensors] sensord exits on any error Andy Poling
2008-12-05 20:27 ` Jean Delvare
2008-12-06 0:34 ` Andy Poling
2008-12-06 8:48 ` Jean Delvare
2008-12-12 8:01 ` Jean Delvare
2008-12-12 21:45 ` Andy Poling
2008-12-14 15:44 ` Jean Delvare [this message]
2008-12-16 9:05 ` Andy Poling
2008-12-16 9:29 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081214164429.3972b6fe@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.