]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: Abort execution of actions that yield on a final evaluation
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Jul 2020 09:59:58 +0000 (11:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 30 Jul 2020 07:31:09 +0000 (09:31 +0200)
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.

src/hlua.c

index 1227db4367274f1614f912476924f6f5dd061781..63ca26b88b98ca71e9176056197b5c169c6bdf25 100644 (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;