]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Assign an ID for each HTTP request and log it in debug lines.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 16 Jan 2016 19:47:53 +0000 (21:47 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 16 Jan 2016 19:47:53 +0000 (21:47 +0200)
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.

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

index d1b6a193d30bc5b9eb7bc1b5a1c297cf2f366d07..ac6b250ab21f29e38fe21f75a9909808d7f0a972 100644 (file)
@@ -60,6 +60,7 @@ struct http_client_request {
        pool_t pool;
        unsigned int refcount;
        const char *label;
+       unsigned int id;
 
        struct http_client_request *prev, *next;
 
@@ -445,7 +446,7 @@ static inline const char *
 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;
index ad28ebe96791ef67b463c369591eabf13906415b..e62ac7d7e5e2b6afc38d56cc6d482fccdb211ccc 100644 (file)
@@ -63,6 +63,7 @@ static struct http_client_request *
 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 @@ http_client_request_new(struct http_client *client, const char *method,
        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 @@ static void http_client_request_do_submit(struct http_client_request *req)
        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)