]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: hlua: Fix receive API for TCP applets to properly handle shutdowns
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 26 May 2025 16:11:19 +0000 (18:11 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 May 2025 05:53:19 +0000 (07:53 +0200)
commitbc4c3c79693e8ddb6d0eb5368935ea965cf03277
tree7e4afdf812b8376383c11d52a4a07300418d9321
parentc0ecef71d7ceaf404bc18241bdb878a4e72033b4
BUG/MEDIUM: hlua: Fix receive API for TCP applets to properly handle shutdowns

An optional timeout was added to AppletTCP.receive() to interrupt calls after a
delay. It was mandatory to be able to implement interactive applets (like
trisdemo). However, this broke the API and it made impossible to differentiate
the shutdowns from the delays expirations. Indeed, in both cases, an empty
string was returned.

Because historically an empty string was used to notify a connection shutdown,
it should not be changed. So now, 'nil' value is returned when no data was
available before the delay expiration.

The new AppletTCP:try_receive() function was also affected. To fix it, instead
of stating there is no delay when a receive is tried, an expired delay is
set. Concretely TICK_ETERNITY was replaced by now_ms.

Finally, AppletTCP:getline() function is not concerned for now because there
is no way to interrupt it after some delay.

The documentation and trisdemo lua script were updated accordingly.

This patch depends on "BUG/MEDIUM: hlua: Properly detect shudowns for TCP
applets based on the new API". However, it is a 3.2-specific issue, so no
backport is needed.
doc/lua-api/index.rst
examples/lua/trisdemo.lua
src/hlua.c