[Asterisk-code-review] main/utils: Don't emit an ERROR message if the read end of a... (asterisk[11])
Matt Jordan
asteriskteam at digium.com
Sun Dec 13 13:19:42 CST 2015
Matt Jordan has uploaded a new change for review.
https://gerrit.asterisk.org/1810
Change subject: main/utils: Don't emit an ERROR message if the read end of a pipe closes
......................................................................
main/utils: Don't emit an ERROR message if the read end of a pipe closes
An ERROR or WARNING message should generally indicate that something has gone
wrong in Asterisk. In the case of writing to a file descriptor, Asterisk is not
in control of when the far end closes its reading on a file descriptor. If it
does this uncleanly, that isn't a bug or error in Asterisk - and in fact, can
be gracefully handled by simply handling EPIPE appropriately.
Currently, when this happens, a user would see the following somewhat cryptic
ERROR message:
"utils.c: write() returned error: Broken pipe"
There's a few problems with this:
(1) It doesn't provide any context, other than 'something broke a pipe'
(2) As noted, it isn't actually an error in Asterisk
(3) It can get rather spammy if the thing breaking the pipe occurs often, such
as a FastAGI server
(4) Spammy ERROR messages make Asterisk appear to be having issues, or can even
make legitimate issues
This patch changes ast_carefulwrite to only log an ERROR if we actually had one
that was reasonably under our control. For debugging purposes, we still emit
a debug message if we detect that the far side has stopped reading.
Change-Id: Ia503bb1efcec685fa6f3017bedf98061f8e1b566
---
M main/utils.c
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/10/1810/1
diff --git a/main/utils.c b/main/utils.c
index 3fa0b76..c1c03af 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1390,7 +1390,11 @@
if (res < 0 && errno != EAGAIN && errno != EINTR) {
/* fatal error from write() */
- ast_log(LOG_ERROR, "write() returned error: %s\n", strerror(errno));
+ if (errno == EPIPE) {
+ ast_debug(1, "write() failed due to reading end being closed: %s\n", strerror(errno));
+ } else {
+ ast_log(LOG_ERROR, "write() returned error: %s\n", strerror(errno));
+ }
return -1;
}
--
To view, visit https://gerrit.asterisk.org/1810
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia503bb1efcec685fa6f3017bedf98061f8e1b566
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list