dovecot-2.2: lib-http: Use [io]_stream_get_error() instead of ju...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 6 19:03:25 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/e67095b8486e
changeset: 16941:e67095b8486e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 06 19:03:10 2013 +0200
description:
lib-http: Use [io]_stream_get_error() instead of just errno strings.

diffstat:

 src/lib-http/http-client-connection.c |  10 ++++++----
 src/lib-http/http-client-request.c    |  20 ++++++++++++--------
 src/lib-http/test-http-client.c       |   7 ++++---
 3 files changed, 22 insertions(+), 15 deletions(-)

diffs (99 lines):

diff -r 38f404297728 -r e67095b8486e src/lib-http/http-client-connection.c
--- a/src/lib-http/http-client-connection.c	Wed Nov 06 17:13:53 2013 +0200
+++ b/src/lib-http/http-client-connection.c	Wed Nov 06 19:03:10 2013 +0200
@@ -361,7 +361,7 @@
 		/* retry pending requests if possible */
 		error = _conn->input == NULL ? "Connection lost" :
 			t_strdup_printf("Connection lost: %s",
-					strerror(_conn->input->stream_errno));
+					i_stream_get_error(_conn->input));
 		http_client_connection_debug(conn, "%s", error);
 		http_client_connection_retry_requests(conn,
 			HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST, error);
@@ -646,7 +646,8 @@
 			t_strdup_printf("Connection lost: read(%s) failed: %s",
 					i_stream_get_name(conn->conn.input),
 					stream_errno != 0 ?
-					strerror(stream_errno) : "EOF"));
+					i_stream_get_error(conn->conn.input) :
+					"EOF"));
 		return;
 	}
 
@@ -681,8 +682,9 @@
 		if (ret < 0) {
 			http_client_connection_abort_temp_error(&conn,
 				HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST,
-				t_strdup_printf("Connection lost: write(%s) failed: %m",
-						o_stream_get_name(output)));
+				t_strdup_printf("Connection lost: write(%s) failed: %s",
+						o_stream_get_name(output),
+						o_stream_get_error(output)));
 		}
 		return ret;
 	}
diff -r 38f404297728 -r e67095b8486e src/lib-http/http-client-request.c
--- a/src/lib-http/http-client-request.c	Wed Nov 06 17:13:53 2013 +0200
+++ b/src/lib-http/http-client-request.c	Wed Nov 06 19:03:10 2013 +0200
@@ -256,8 +256,9 @@
 	req->payload_input = input;
 	if ((ret = i_stream_get_size(input, TRUE, &req->payload_size)) <= 0) {
 		if (ret < 0) {
-			i_error("i_stream_get_size(%s) failed: %m",
-				i_stream_get_name(input));
+			i_error("i_stream_get_size(%s) failed: %s",
+				i_stream_get_name(input),
+				i_stream_get_error(input));
 		}
 		req->payload_size = 0;
 		req->payload_chunked = TRUE;
@@ -505,14 +506,16 @@
 		/* we're in the middle of sending a request, so the connection
 		   will also have to be aborted */
 		errno = req->payload_input->stream_errno;
-		*error_r = t_strdup_printf("read(%s) failed: %m",
-					   i_stream_get_name(req->payload_input));
+		*error_r = t_strdup_printf("read(%s) failed: %s",
+					   i_stream_get_name(req->payload_input),
+					   i_stream_get_error(req->payload_input));
 		ret = -1;
 	} else if (output->stream_errno != 0) {
 		/* failed to send request */
 		errno = output->stream_errno;
-		*error_r = t_strdup_printf("write(%s) failed: %m",
-					   o_stream_get_name(output));
+		*error_r = t_strdup_printf("write(%s) failed: %s",
+					   o_stream_get_name(output),
+					   o_stream_get_error(output));
 		ret = -1;
 	} else {
 		i_assert(ret >= 0);
@@ -631,8 +634,9 @@
 	req->state = HTTP_REQUEST_STATE_PAYLOAD_OUT;
 	o_stream_cork(output);
 	if (o_stream_sendv(output, iov, N_ELEMENTS(iov)) < 0) {
-		*error_r = t_strdup_printf("write(%s) failed: %m",
-					   o_stream_get_name(output));
+		*error_r = t_strdup_printf("write(%s) failed: %s",
+					   o_stream_get_name(output),
+					   o_stream_get_error(output));
 		ret = -1;
 	}
 
diff -r 38f404297728 -r e67095b8486e src/lib-http/test-http-client.c
--- a/src/lib-http/test-http-client.c	Wed Nov 06 17:13:53 2013 +0200
+++ b/src/lib-http/test-http-client.c	Wed Nov 06 19:03:10 2013 +0200
@@ -31,9 +31,10 @@
 		i_info("DEBUG: REQUEST: NEED MORE DATA");
 		/* we will be called again for this request */
 	} else {
-		if (req->payload->stream_errno != 0)
-			i_error("REQUEST PAYLOAD READ ERROR: %m");
-		else
+		if (req->payload->stream_errno != 0) {
+			i_error("REQUEST PAYLOAD READ ERROR: %s",
+				i_stream_get_error(req->payload));
+		} else
 			i_info("DEBUG: REQUEST: Finished");
 		io_remove(&req->io);
 		i_stream_unref(&req->payload);


More information about the dovecot-cvs mailing list