Ack.
Maybe you could consider if it makes sense to do the following
improvement, though:
Log to syslog ONCE until the error goes away. This could be done for all
values of errno (execpt EAGAIN and EINTR) by introducing a flag. When
write fails, log to syslog once and set the flag. Don't log any more to
syslog as long as the flag is set. If write is successful again, clear
the flag.
BTW from a quick look this code seems to contain several problems (not
related to your patch). Why is it checking for EAGAIN when the file was
not opened non-blocking? Shouldn't it check for EINTR instead? And maybe
the file ought to be opened non-blocking? Further up in the code, I see
wrong usage of return value from snprintf and vsnprintf: these functions
return -1 on error, and they can return a value larger than maximum
buffer size in case the string would have overflowed the buffer. This is
not checked by the code! And the loop (why is it using goto instead of
an ordinary while loop, btw?) is wrong. If we get EAGAIN, the variable
"i" will have the value -1, which is used as size in the next call to
write(trace_fd, log_string, i). Sigh! Three bugs in the same function.
regards,
Anders Widell
2013-12-13 13:47, Hans Feldt skrev:
> osaf/libs/core/common/logtrace.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> diff --git a/osaf/libs/core/common/logtrace.c
> b/osaf/libs/core/common/logtrace.c
> --- a/osaf/libs/core/common/logtrace.c
> +++ b/osaf/libs/core/common/logtrace.c
> @@ -120,7 +120,7 @@ write_retry:
> if (i == -1) {
> if (errno == EAGAIN)
> goto write_retry;
> - else
> + else if (errno != ENOSPC)
> syslog(LOG_ERR, "logtrace: write failed, %s",
> strerror(errno));
> }
> }
--
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel