Hi Tobi, please consider the attached patch which changes the error handling in `rrd_strerror' a little. A user of collectd got the following error message:
mmaping file '...': strerror_r failed. sorry!
It would have helped to debug his problem to know which error actually
occurred. With the attached patch, the error message will become:
mmaping file '...': strerror_r (123) failed. sorry!
Where `123' is the error code passed to `rrd_strerror'.
I'm afraid I don't know why `strerror_r' failed in this case, the error
that was passed to it was most likely EINTR, so nothing fancy.. But I
have a suspicion..:
Please note, that error checking with
if (strerror_r (...)) { ... }
is problematic for portability: Some systems (the GNU libc, unless given
_XOPEN_SOURCE=600, for example) export a version of `strerror_r' that
returns a pointer to the buffer it just filled, so it can be used just
like `strerror'. On such systems the block will always be executed
*except* when an error occurred.
Regards,
-octo
--
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
Index: src/rrd_thread_safe.c
===================================================================
--- src/rrd_thread_safe.c (revision 1746)
+++ src/rrd_thread_safe.c (working copy)
@@ -60,10 +60,12 @@
{
rrd_context_t *ctx = rrd_get_context();
- if (strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr)))
- return "strerror_r failed. sorry!";
- else
- return ctx->lib_errstr;
+ if (strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr))) {
+ snprintf (ctx->lib_errstr, sizeof(ctx->lib_errstr),
+ "strerror_r (%i) failed. sorry!", err);
+ ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = 0;
+ }
+ return ctx->lib_errstr;
}
#else
#undef strerror
signature.asc
Description: Digital signature
_______________________________________________ rrd-developers mailing list [email protected] https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers
