From e9314fb7a7cc63805bddb4730ab92ef565647160 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 4 Apr 2023 21:41:10 +0200 Subject: [PATCH] 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. --- include/haproxy/event_hdl-t.h | 2 ++ src/event_hdl.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/haproxy/event_hdl-t.h b/include/haproxy/event_hdl-t.h index a8062d13e..77e7d933c 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 5ec81236c..7bf0f16d5 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