]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua/event_hdl: fix return type for hlua_event_hdl_cb_data_push_args
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 27 Mar 2023 16:16:21 +0000 (18:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 21 Apr 2023 12:36:45 +0000 (14:36 +0200)
Changing hlua_event_hdl_cb_data_push_args() return type to void since it
does not return anything useful.
Also changing its name to hlua_event_hdl_cb_push_args() since it does more
than just pushing cb data argument (it also handles event type and mgmt).

Errors catched by the function are reported as lua errors.

src/hlua.c

index 747e6e8658468ed77cb3ab4fb3c48481982903d1..a20ab03fade48a72eb234c821a4882d465deeb13 100644 (file)
@@ -9029,13 +9029,21 @@ static void hlua_event_handler(struct hlua *hlua)
        }
 }
 
-__LJMP static int hlua_event_hdl_cb_data_push_args(struct hlua_event_sub *hlua_sub,
-                                                   struct event_hdl_sub_type event, void *data)
+/* This function pushes various arguments such as event type and event data to
+ * the lua function that will be called to consume the event.
+ */
+__LJMP static void hlua_event_hdl_cb_push_args(struct hlua_event_sub *hlua_sub,
+                                               struct event_hdl_async_event *e)
 {
        struct hlua *hlua = hlua_sub->hlua;
+       struct event_hdl_sub_type event = e->type;
+       void *data = e->data;
 
+       /* push event type */
        hlua->nargs = 1;
        lua_pushstring(hlua->T, event_hdl_sub_type_to_string(event));
+
+       /* push event data (according to event type) */
        if (event_hdl_sub_family_equal(EVENT_HDL_SUB_SERVER, event)) {
                struct event_hdl_cb_data_server *e_server = data;
                struct proxy *px;
@@ -9079,8 +9087,6 @@ __LJMP static int hlua_event_hdl_cb_data_push_args(struct hlua_event_sub *hlua_s
        /* sub mgmt */
        hlua->nargs += 1;
        hlua_fcn_new_event_sub(hlua->T, hlua_sub->sub);
-
-       return 1;
 }
 
 /* events runner: if there's an ongoing hlua event handling process, finish it
@@ -9160,10 +9166,7 @@ static struct task *hlua_event_runner(struct task *task, void *context, unsigned
 
                /* push args */
                hlua_sub->hlua->nargs = 0;
-               if (!hlua_event_hdl_cb_data_push_args(hlua_sub, event->type, event->data)) {
-                       RESET_SAFE_LJMP(hlua_sub->hlua);
-                       goto skip_event;
-               }
+               MAY_LJMP(hlua_event_hdl_cb_push_args(hlua_sub, event));
 
                /* At this point the execution is safe. */
                RESET_SAFE_LJMP(hlua_sub->hlua);