Mercurial > dovecot > core-2.2
changeset 16941:e67095b8486e
lib-http: Use [io]_stream_get_error() instead of just errno strings.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 06 Nov 2013 19:03:10 +0200 |
parents | 38f404297728 |
children | 1c9ecb6bcccc |
files | src/lib-http/http-client-connection.c src/lib-http/http-client-request.c src/lib-http/test-http-client.c |
diffstat | 3 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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; }
--- 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);