Mercurial > dovecot > core-2.2
changeset 19580:9703d0af2e3b
lib-http: Assign an ID for each HTTP request and log it in debug lines.
The ID stays the same when request is retried. Added a "Req" prefix so it's
easier to search for the IDs. Based on patch by Stephan Bosch.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sat, 16 Jan 2016 21:47:53 +0200 |
parents | f82dca1e2547 |
children | d622d8603290 |
files | src/lib-http/http-client-private.h src/lib-http/http-client-request.c |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-client-private.h Sat Jan 16 21:31:55 2016 +0200 +++ b/src/lib-http/http-client-private.h Sat Jan 16 21:47:53 2016 +0200 @@ -60,6 +60,7 @@ pool_t pool; unsigned int refcount; const char *label; + unsigned int id; struct http_client_request *prev, *next; @@ -445,7 +446,7 @@ http_client_request_label(struct http_client_request *req) { if (req->label == NULL) { - return t_strdup_printf("[%s %s%s]", + return t_strdup_printf("[Req%u: %s %s%s]", req->id, req->method, http_url_create(&req->origin_url), req->target); } return req->label;
--- a/src/lib-http/http-client-request.c Sat Jan 16 21:31:55 2016 +0200 +++ b/src/lib-http/http-client-request.c Sat Jan 16 21:47:53 2016 +0200 @@ -63,6 +63,7 @@ http_client_request_new(struct http_client *client, const char *method, http_client_request_callback_t *callback, void *context) { + static unsigned int id_counter = 0; pool_t pool; struct http_client_request *req; @@ -71,6 +72,7 @@ req->pool = pool; req->refcount = 1; req->client = client; + req->id = ++id_counter; req->method = p_strdup(pool, method); req->callback = callback; req->context = context; @@ -485,7 +487,7 @@ req->authority = p_strdup(req->pool, authority); /* debug label */ - req->label = p_strdup_printf(req->pool, "[%s %s]", req->method, target); + req->label = p_strdup_printf(req->pool, "[Req%u: %s %s]", req->id, req->method, target); /* update request target */ if (req->connect_tunnel || have_proxy)