BUG/MINOR: lua: Yield in channel functions only if lua context can yield
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Aug 2021 09:58:37 +0000 (11:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 20 Sep 2021 14:38:48 +0000 (16:38 +0200)
commitd33a546594399bbacc8ae9db3e1adc5776c55a17
tree608a3dae8886db36bd744353132a702b095a7d27
parentefca07cae13ee798509050f8ecc55d3c5e2b187d
BUG/MINOR: lua: Yield in channel functions only if lua context can yield

When a script is executed, it is not always allowed to yield. Lua sample
fetches and converters cannot yield. For lua actions, it depends on the
context. When called from tcp content ruleset, an action may yield until the
expiration of the inspect-delay timeout. From http rulesets, yield is not
possible.

Thus, when channel functions (dup, get, append, send...) are called, instead
of yielding when it is not allowed and triggering an error, we just give
up. In this case, some functions do nothing (dup, append...), some others
just interrupt the in-progress job (send, forward...). But, because these
functions don't yield anymore when it is not allowed, the script regains the
control and can continue its execution.

This patch depends on "MINOR: lua: Add a flag on lua context to know the
yield capability at run time". Both may be backported in all stable
versions. However, because nobody notice this bug till now, it is probably
not necessary, excepted if someone ask for it.

(cherry picked from commit 055310ff49749ab1f4b3e4bb2ea675fbc597f3f3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/hlua.c