[asterisk-commits] http.c: Reduce log spam (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 11 19:42:11 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5964 )

Change subject: http.c:  Reduce log spam
......................................................................

http.c:  Reduce log spam

Messages like "fwrite() failed: Connection reset by peer" are no
help whatsoever, especially since they can be caused simply by a
client disconnecting.

* Make those WARNINGs DEBUGs.
* Check the return from ast_iostream_printf of headers.

Change-Id: I17bd5f3621514152a7b2b263c801324c5e96568b
---
M main/http.c
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/http.c b/main/http.c
index ea85a28..7191eb5 100644
--- a/main/http.c
+++ b/main/http.c
@@ -508,7 +508,7 @@
 	send_content = method != AST_HTTP_HEAD || status_code >= 400;
 
 	/* send http header */
-	ast_iostream_printf(ser->stream,
+	if (ast_iostream_printf(ser->stream,
 		"HTTP/1.1 %d %s\r\n"
 		"%s"
 		"Date: %s\r\n"
@@ -526,13 +526,16 @@
 		http_header ? ast_str_buffer(http_header) : "",
 		content_length,
 		send_content && out && ast_str_strlen(out) ? ast_str_buffer(out) : ""
-		);
+		) <= 0) {
+		ast_debug(1, "ast_iostream_printf() failed: %s\n", strerror(errno));
+		close_connection = 1;
+	}
 
 	/* send content */
-	if (send_content && fd) {
+	if (!close_connection && send_content && fd) {
 		while ((len = read(fd, buf, sizeof(buf))) > 0) {
 			if (ast_iostream_write(ser->stream, buf, len) != len) {
-				ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
+				ast_debug(1, "ast_iostream_write() failed: %s\n", strerror(errno));
 				close_connection = 1;
 				break;
 			}

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I17bd5f3621514152a7b2b263c801324c5e96568b
Gerrit-Change-Number: 5964
Gerrit-PatchSet: 3
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170711/b228c953/attachment-0001.html>


More information about the asterisk-commits mailing list