Skip to content

Commit

Permalink
lib-http: Add http_client_request_stats.first_sent_msecs
Browse files Browse the repository at this point in the history
Also rename sent_msecs to last_sent_msecs.
  • Loading branch information
sirainen committed Apr 10, 2017
1 parent 869fc20 commit e88a770
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/lib-http/http-client-request.c
Expand Up @@ -597,10 +597,16 @@ void http_client_request_get_stats(struct http_client_request *req,
diff_msecs = timeval_diff_msecs(&ioloop_timeval, &req->submit_time);
stats_r->total_msecs = (unsigned int)I_MAX(diff_msecs, 0);

/* elapsed time since message was first sent */
if (req->first_sent_time.tv_sec > 0) {
diff_msecs = timeval_diff_msecs(&ioloop_timeval, &req->first_sent_time);
stats_r->first_sent_msecs = (unsigned int)I_MAX(diff_msecs, 0);
}

/* elapsed time since message was last sent */
if (req->sent_time.tv_sec > 0) {
diff_msecs = timeval_diff_msecs(&ioloop_timeval, &req->sent_time);
stats_r->sent_msecs = (unsigned int)I_MAX(diff_msecs, 0);
stats_r->last_sent_msecs = (unsigned int)I_MAX(diff_msecs, 0);
}

if (req->conn != NULL) {
Expand Down Expand Up @@ -644,9 +650,9 @@ void http_client_request_append_stats_text(struct http_client_request *req,

http_client_request_get_stats(req, &stats);

if (stats.sent_msecs > 0) {
if (stats.last_sent_msecs > 0) {
str_printfa(str, "sent %u.%03u secs ago",
stats.sent_msecs/1000, stats.sent_msecs%1000);
stats.last_sent_msecs/1000, stats.last_sent_msecs%1000);
} else {
str_append(str, "not yet sent");
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib-http/http-client.h
Expand Up @@ -186,8 +186,10 @@ struct http_client_tunnel {
struct http_client_request_stats {
/* Total elapsed time since message was submitted */
unsigned int total_msecs;
/* Elapsed time since message was first sent */
unsigned int first_sent_msecs;
/* Elapsed time since message was last sent */
unsigned int sent_msecs;
unsigned int last_sent_msecs;

/* Time spent in other ioloops */
unsigned int other_ioloop_msecs;
Expand Down

0 comments on commit e88a770

Please sign in to comment.