From: Christopher Faulet Date: Mon, 26 May 2025 16:24:53 +0000 (+0200) Subject: BUG/MEDIUM: hlua: Properly detect shudowns for TCP applets based on the new API X-Git-Tag: v3.0.11~10 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=272c1775a03b4bba3ac5d264f9024b563e21842e;p=haproxy-3.0.git BUG/MEDIUM: hlua: Properly detect shudowns for TCP applets based on the new API The internal function responsible to receive data for TCP applets with internal buffers is buggy. Indeed, for these applets, the buffer API is used to get data. So there is no tests on the SE to properly detect connection shutdowns. So, it must be performed by hand after the call to b_getblk_nc(). This patch must be backported as far as 3.0. (cherry picked from commit c64781c2c8b307fba7499fc70102d4246e850240) Signed-off-by: Christopher Faulet (cherry picked from commit ecc8126ef97836044b1bc962fd4b9c91e89c353f) Signed-off-by: Christopher Faulet --- diff --git a/src/hlua.c b/src/hlua.c index 2f7a8f2..b078d26 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5301,8 +5301,11 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont size_t len2; /* Read the maximum amount of data available. */ - if (luactx->appctx->flags & APPCTX_FL_INOUT_BUFS) + if (luactx->appctx->flags & APPCTX_FL_INOUT_BUFS) { ret = b_getblk_nc(&luactx->appctx->inbuf, &blk1, &len1, &blk2, &len2, 0, b_data(&luactx->appctx->inbuf)); + if (ret == 0 && se_fl_test(luactx->appctx->sedesc, SE_FL_SHW)) + ret = -1; + } else ret = co_getblk_nc(sc_oc(sc), &blk1, &len1, &blk2, &len2);