From: Aurelien DARRAGON Date: Tue, 4 Apr 2023 19:41:10 +0000 (+0200) Subject: MINOR: event_hdl: provide event->when for advanced handlers X-Git-Tag: v2.8-dev8~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e9314fb7a7cc63805bddb4730ab92ef565647160;p=thirdparty%2Fhaproxy.git MINOR: event_hdl: provide event->when for advanced handlers For advanced async handlers only (Registered using EVENT_HDL_ASYNC_TASK() macro): event->when is provided as a struct timeval and fetched from 'date' haproxy global variable. Thanks to 'when', related event consumers will be able to timestamp events, even if they don't work in real-time or near real-time. Indeed, unlike sync or normal async handlers, advanced async handlers could purposely delay the consumption of pending events, which means that the date wouldn't be accurate if computed directly from within the handler. --- diff --git a/include/haproxy/event_hdl-t.h b/include/haproxy/event_hdl-t.h index a8062d13eb..77e7d933cd 100644 --- a/include/haproxy/event_hdl-t.h +++ b/include/haproxy/event_hdl-t.h @@ -23,6 +23,7 @@ # define _HAPROXY_EVENT_HDL_T_H #include +#include #include @@ -120,6 +121,7 @@ struct event_hdl_async_event */ void *data; void *private; + struct timeval when; struct event_hdl_sub_mgmt sub_mgmt; }; diff --git a/src/event_hdl.c b/src/event_hdl.c index 5ec81236c3..7bf0f16d5b 100644 --- a/src/event_hdl.c +++ b/src/event_hdl.c @@ -836,6 +836,7 @@ static int _event_hdl_publish(event_hdl_sub_list *sub_list, struct event_hdl_sub } new_event->type = e_type; new_event->private = cur_sub->hdl.private; + new_event->when = date; new_event->sub_mgmt = EVENT_HDL_SUB_MGMT_ASYNC(cur_sub); if (data) { /* if this fails, please adjust EVENT_HDL_ASYNC_EVENT_DATA in