From 28d17e26b846e485eac36d82da3c5439524240c7 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 12 Jun 2023 09:16:27 +0200 Subject: [PATCH] BUG/MEDIUM: hlua: Use front SC to detect EOI in HTTP applets' receive functions When an HTTP applet tries to get request data, we must take care to properly detect the end of the message. It an empty HTX message with the SC_FL_EOI flag set on the front SC. However, an issue was introduced during the SC refactoring performed in the 2.8. The backend SC is tested instead of the frontend one. Because of this bug, the receive functions hang because the test on SC_FL_EOI flag never succeeds. Of course, by checking the frontend SC (the opposite SC to the one attached to the appctx), it works. This patch should fix the issue #2180. It must be backported to the 2.8. --- src/hlua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 742c82448..ae0d412a4 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5353,7 +5353,7 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K /* The message was fully consumed and no more data are expected * (EOM flag set). */ - if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI)) + if (htx_is_empty(htx) && (sc_opposite(sc)->flags & SC_FL_EOI)) stop = 1; htx_to_buf(htx, &req->buf); @@ -5445,7 +5445,7 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon /* The message was fully consumed and no more data are expected * (EOM flag set). */ - if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI)) + if (htx_is_empty(htx) && (sc_opposite(sc)->flags & SC_FL_EOI)) len = 0; htx_to_buf(htx, &req->buf);