]> 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)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 27 Feb 2018 09:45:26 +0000 (10:45 +0100)
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 dddadd8975b2caa898db4db80d722dda63f68b4a..8ba2f5df45729483bcaf9eb4c1b8c4b5917d8828 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 7c530f504962ce7062535c96cdd2ad5a1efd329c..eee589bf21cce468e18198f1de3b901a199787cd 100644 (file)
@@ -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