[Asterisk-code-review] ast careful fwrite to support EPIPE gracefully (asterisk[13])

Kirill Katsnelson asteriskteam at digium.com
Wed Jan 25 23:04:38 CST 2017


Kirill Katsnelson has uploaded a new change for review. ( 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.

Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
---
M main/utils.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/24/4824/1

diff --git a/main/utils.c b/main/utils.c
index 253df8d..ac07189 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1453,7 +1453,7 @@
 
 		if (ferror(f) && errno != EINTR && errno != EAGAIN) {
 			/* fatal error from fwrite() */
-			if (!feof(f)) {
+			if (!feof(f) && errno != EPIPE) {
 				/* 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));
 			}
@@ -1485,7 +1485,7 @@
 			usleep(1);
 			continue;
 		}
-		if (errno && !feof(f)) {
+		if (errno && !feof(f) && errno != EPIPE) {
 			/* 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));
 		}

-- 
To view, visit https://gerrit.asterisk.org/4824
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a67335cd6526608bb9b78f796c626b1677664b8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Kirill Katsnelson <kkm at smartaction.com>



More information about the asterisk-code-review mailing list