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.
This commit is contained in:
Christopher Faulet 2020-07-28 11:59:58 +02:00
parent 385101e538
commit 498c483009

View File

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