diff --git a/src/lib-http/http-client-private.h b/src/lib-http/http-client-private.h index 8d3544e971..85e7a4d574 100644 --- a/src/lib-http/http-client-private.h +++ b/src/lib-http/http-client-private.h @@ -121,7 +121,7 @@ struct http_client_request { uoff_t response_offset, request_offset; uoff_t bytes_in, bytes_out; - unsigned int attempts; + unsigned int attempts, send_attempts; unsigned int redirects; uint64_t sent_global_ioloop_usecs; uint64_t sent_http_ioloop_usecs; diff --git a/src/lib-http/http-client-request.c b/src/lib-http/http-client-request.c index dddadd8975..8ba2f5df45 100644 --- a/src/lib-http/http-client-request.c +++ b/src/lib-http/http-client-request.c @@ -703,7 +703,8 @@ void http_client_request_get_stats(struct http_client_request *req, /* number of attempts for this request */ stats_r->attempts = req->attempts; - + /* number of send attempts for this request */ + stats_r->send_attempts = req->send_attempts; } void http_client_request_append_stats_text(struct http_client_request *req, @@ -720,14 +721,16 @@ void http_client_request_append_stats_text(struct http_client_request *req, str_printfa(str, "queued %u.%03u secs ago", stats.total_msecs/1000, stats.total_msecs%1000); + if (stats.attempts > 0) + str_printfa(str, ", %u times retried", stats.attempts); - if (stats.first_sent_msecs == 0) + if (stats.send_attempts == 0) { str_append(str, ", not yet sent"); - else { - str_printfa(str, ", %u attempts in %u.%03u secs", - stats.attempts + 1, + } else { + str_printfa(str, ", %u send attempts in %u.%03u secs", + stats.send_attempts, stats.first_sent_msecs/1000, stats.first_sent_msecs%1000); - if (stats.attempts > 0) { + if (stats.send_attempts > 1) { str_printfa(str, ", %u.%03u in last attempt", stats.last_sent_msecs/1000, stats.last_sent_msecs%1000); @@ -1294,6 +1297,7 @@ static int http_client_request_send_real(struct http_client_request *req, iov[2].iov_len = 2; req->state = HTTP_REQUEST_STATE_PAYLOAD_OUT; + req->send_attempts++; if (req->first_sent_time.tv_sec == 0) req->first_sent_time = ioloop_timeval; req->sent_time = ioloop_timeval; diff --git a/src/lib-http/http-client.h b/src/lib-http/http-client.h index 7c530f5049..eee589bf21 100644 --- a/src/lib-http/http-client.h +++ b/src/lib-http/http-client.h @@ -201,8 +201,11 @@ struct http_client_request_stats { /* Total time spent on waiting for file locks */ unsigned int lock_msecs; - /* Number of attempts for this request */ + /* Number of times this request was retried */ unsigned int attempts; + /* Number of times the client attempted to actually send the request + to a server */ + unsigned int send_attempts; }; typedef void