From: Timo Sirainen Date: Fri, 4 Dec 2015 11:46:00 +0000 (+0200) Subject: lib-http: Give a better error message if request times out. X-Git-Tag: 2.2.20~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=231629a38dbfbf5dc56180425de3e883310ad853;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Give a better error message if request times out. Instead of just giving the configured timeout, log how long the timeout actually took for the oldest request in wait list. Also if the request was retried, log how many times the request was sent and how long the request took in total. --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index 6bf3a38ad2..c2353fc2fe 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -257,13 +257,24 @@ void http_client_connection_check_idle(struct http_client_connection *conn) static void http_client_connection_request_timeout(struct http_client_connection *conn) { - unsigned int msecs = conn->client->set.request_timeout_msecs; - + struct http_client_request *const *requestp; + unsigned int timeout_msecs, total_msecs; + string_t *str = t_str_new(64); + + requestp = array_idx(&conn->request_wait_list, 0); + timeout_msecs = timeval_diff_msecs(&ioloop_timeval, &(*requestp)->sent_time); + total_msecs = timeval_diff_msecs(&ioloop_timeval, &(*requestp)->submit_time); + + str_printfa(str, "No response for request in %u.%03u secs", + timeout_msecs/1000, timeout_msecs%1000); + if ((*requestp)->attempts > 0) { + str_printfa(str, " (%u attempts in %u.%03u secs)", + (*requestp)->attempts + 1, + total_msecs/1000, total_msecs%1000); + } conn->conn.input->stream_errno = ETIMEDOUT; http_client_connection_abort_temp_error(&conn, - HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, t_strdup_printf( - "No response for request in %u.%03u secs", - msecs/1000, msecs%1000)); + HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT, str_c(str)); } void http_client_connection_start_request_timeout(