dovecot-2.2: lib-http: Give a better error message if request ti...

dovecot at dovecot.org dovecot at dovecot.org
Fri Dec 4 11:46:17 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/9a81cb959ce6
changeset: 19461:9a81cb959ce6
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Dec 04 13:46:00 2015 +0200
description:
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.

diffstat:

 src/lib-http/http-client-connection.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 1b32cd3b872c -r 9a81cb959ce6 src/lib-http/http-client-connection.c
--- a/src/lib-http/http-client-connection.c	Fri Dec 04 13:27:28 2015 +0200
+++ b/src/lib-http/http-client-connection.c	Fri Dec 04 13:46:00 2015 +0200
@@ -257,13 +257,24 @@
 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(


More information about the dovecot-cvs mailing list