]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Fix request statistics text to properly report send attempts.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 27 Feb 2018 09:45:26 +0000 (10:45 +0100)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 10:05:47 +0000 (13:05 +0300)
If the request was first sent in the same ioloop cycle in which the text is
generated, the text would claim it was not sent at all yet.

With this commit the text now explicitly makes the distinction between request
attempts and actual send attempts. The number of attempts is increased at each
retry, while the send attempts are increased each time the request is actually
being sent to a server.

src/lib-http/http-client-private.h
src/lib-http/http-client-request.c
src/lib-http/http-client.h

index 8d3544e971f1d171d04d2347ee11a773f7974915..85e7a4d574dc704a10cb0e3c55e2a5c5ff9b6416 100644 (file)
@@ -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;
index b9141a83f94c8f8e31278eab258c4e8351138951..13d6a9565b594723d276e5a7f35f1b398a5d6b21 100644 (file)
@@ -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;
index 1edfe3d0b7b208554633165ce23234d770e9e17a..79b963ce982713c805a563e606ecc4586c444919 100644 (file)
@@ -205,8 +205,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