]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-request - Preserve global events' reason_code in request events
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Apr 2021 17:27:45 +0000 (20:27 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 29 Sep 2021 10:09:58 +0000 (10:09 +0000)
Since HTTP requests are asynchronous, it's possible that the global events
go away before the HTTP request is finished. This way the reason_code will
be preserved in http_request_finished event.

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

index 0a471f7f5d56415922c7a63db153b7607ae5e35d..8453294cae3acd96b62b3518e5b2d354fdfba1f2 100644 (file)
@@ -119,6 +119,8 @@ http_client_request_new(struct http_client *client, const char *method,
        req->context = context;
        req->date = (time_t)-1;
        req->event = event_create(client->event);
+       event_strlist_copy_recursive(req->event, event_get_global(),
+                                    EVENT_REASON_CODE);
 
        /* Default to client-wide settings: */
        req->max_attempts = client->set.max_attempts;
@@ -242,6 +244,8 @@ void http_client_request_set_event(struct http_client_request *req,
        event_unref(&req->event);
        req->event = event_create(event);
        event_set_forced_debug(req->event, req->client->set.debug);
+       event_strlist_copy_recursive(req->event, event_get_global(),
+                                    EVENT_REASON_CODE);
        http_client_request_update_event(req);
 }