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.
This commit is contained in:
Christopher Faulet 2025-05-26 18:24:53 +02:00
parent 4d4da515f2
commit c64781c2c8

View File

@ -5362,8 +5362,11 @@ __LJMP static int hlua_applet_tcp_recv_try(lua_State *L)
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);