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.
This commit is contained in:
Aurelien DARRAGON 2023-04-04 21:41:10 +02:00 committed by Christopher Faulet
parent ebf58e991a
commit e9314fb7a7
2 changed files with 3 additions and 0 deletions

View File

@ -23,6 +23,7 @@
# define _HAPROXY_EVENT_HDL_T_H
#include <stdint.h>
#include <sys/time.h>
#include <haproxy/api-t.h>
@ -120,6 +121,7 @@ struct event_hdl_async_event
*/
void *data;
void *private;
struct timeval when;
struct event_hdl_sub_mgmt sub_mgmt;
};

View File

@ -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