From: Timo Sirainen Date: Wed, 6 Nov 2013 17:03:10 +0000 (+0200) Subject: lib-http: Use [io]_stream_get_error() instead of just errno strings. X-Git-Tag: 2.2.8~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dde71564d306d07cba63bdf0f40996ffb90ca47a;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Use [io]_stream_get_error() instead of just errno strings. --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index ce151452e2..c1d03cc846 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -361,7 +361,7 @@ static void http_client_connection_destroy(struct connection *_conn) /* 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 @@ static void http_client_connection_input(struct connection *_conn) 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 @@ int http_client_connection_output(struct http_client_connection *conn) 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 --git a/src/lib-http/http-client-request.c b/src/lib-http/http-client-request.c index 8ca4b81537..64f8c2fc1b 100644 --- a/src/lib-http/http-client-request.c +++ b/src/lib-http/http-client-request.c @@ -256,8 +256,9 @@ void http_client_request_set_payload(struct http_client_request *req, 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 @@ int http_client_request_send_more(struct http_client_request *req, /* 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 @@ static int http_client_request_send_real(struct http_client_request *req, 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 --git a/src/lib-http/test-http-client.c b/src/lib-http/test-http-client.c index 83b09a1759..9d2a405dbe 100644 --- a/src/lib-http/test-http-client.c +++ b/src/lib-http/test-http-client.c @@ -31,9 +31,10 @@ static void payload_input(struct http_test_request *req) 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);