[asterisk-commits] ast careful fwrite to support EPIPE gracefully (asterisk[13])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 30 11:52:06 CST 2017
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4824 )
Change subject: ast_careful_fwrite to support EPIPE gracefully
......................................................................
ast_careful_fwrite to support EPIPE gracefully
When a reading end of the network socket is closed by an AMI manager,
the EPIPE is signaled when writing to our end, resulting in the
spurious log error message
ast_careful_fwrite: fwrite() returned error: Broken pipe
Previously EPIPE was handled in ast_carefulwrite() a few lines above,
but not in this function.
ASTERISK-26753
Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
---
M main/utils.c
1 file changed, 9 insertions(+), 3 deletions(-)
Approvals:
George Joseph: Looks good to me, approved; Verified
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/main/utils.c b/main/utils.c
index 253df8d..de7ff8f 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1453,7 +1453,9 @@
if (ferror(f) && errno != EINTR && errno != EAGAIN) {
/* fatal error from fwrite() */
- if (!feof(f)) {
+ if (errno == EPIPE) {
+ ast_debug(1, "fwrite() failed due to reading end being closed: EPIPE\n");
+ } else if (!feof(f)) {
/* Don't spam the logs if it was just that the connection is closed. */
ast_log(LOG_ERROR, "fwrite() returned error: %s\n", strerror(errno));
}
@@ -1486,8 +1488,12 @@
continue;
}
if (errno && !feof(f)) {
- /* Don't spam the logs if it was just that the connection is closed. */
- ast_log(LOG_ERROR, "fflush() returned error: %s\n", strerror(errno));
+ if (errno == EPIPE) {
+ ast_debug(1, "fflush() failed due to reading end being closed: EPIPE\n");
+ } else {
+ /* Don't spam the logs if it was just that the connection is closed. */
+ ast_log(LOG_ERROR, "fflush() returned error: %s\n", strerror(errno));
+ }
}
n = -1;
break;
--
To view, visit https://gerrit.asterisk.org/4824
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Kirill Katsnelson <kkm at smartaction.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kirill Katsnelson <kkm at smartaction.com>
More information about the asterisk-commits
mailing list