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>
Thu, 12 Aug 2021 06:57:07 +0000 (08:57 +0200)
commit2e60aa4dee4a07a8688ba456aa7036b85340cfdd
tree7513c39f191990226fddff7b947d5d7fe43bd3a3
parent1f43a3430e8b3ae017a12225ac7e523b0d42ffa3
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.
src/hlua.c