From: Christopher Faulet Date: Tue, 28 Jul 2020 09:59:58 +0000 (+0200) Subject: BUG/MINOR: lua: Abort execution of actions that yield on a final evaluation X-Git-Tag: v2.3-dev2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=498c483009bfb69e75a35403c758b832d4d997d3;p=thirdparty%2Fhaproxy.git BUG/MINOR: lua: Abort execution of actions that yield on a final evaluation A Lua action may yield. It may happen because the action returns explicitly act.YIELD or because the script itself yield. In the first case, we must abort the script execution if it is the final rule evaluation, i.e if the ACT_OPT_FINAL flag is set. The second case is already covered. This patch must be backported to 2.2. --- diff --git a/src/hlua.c b/src/hlua.c index 1227db4367..63ca26b88b 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -6649,11 +6649,16 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px, act_ret = lua_tointeger(s->hlua->T, -1); /* Set timeout in the required channel. */ - if (act_ret == ACT_RET_YIELD && s->hlua->wake_time != TICK_ETERNITY) { - if (dir == SMP_OPT_DIR_REQ) - s->req.analyse_exp = s->hlua->wake_time; - else - s->res.analyse_exp = s->hlua->wake_time; + if (act_ret == ACT_RET_YIELD) { + if (flags & ACT_OPT_FINAL) + goto err_yield; + + if (s->hlua->wake_time != TICK_ETERNITY) { + if (dir == SMP_OPT_DIR_REQ) + s->req.analyse_exp = s->hlua->wake_time; + else + s->res.analyse_exp = s->hlua->wake_time; + } } goto end; @@ -6694,6 +6699,8 @@ static enum act_return hlua_action(struct act_rule *rule, struct proxy *px, goto end; case HLUA_E_YIELD: + err_yield: + act_ret = ACT_RET_CONT; SEND_ERR(px, "Lua function '%s': aborting Lua processing on expired timeout.\n", rule->arg.hlua_rule->fcn.name); goto end;