]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua: Rely on CF_EOI to detect end of message in HTTP applets
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Aug 2022 13:37:16 +0000 (15:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Aug 2022 13:37:17 +0000 (15:37 +0200)
applet:getline() and applet:receive() functions for HTTP applets must rely
on the channel flags to detect the end of the message and not on HTX
flags. It means CF_EOI must be used instead of HTX_FL_EOM.

It is important because the HTX flag is transient. Because there is no flag
on HTTP applets to save the info, it is not reliable. However CF_EOI once
set is never removed. So it is safer to rely on it. Otherwise, the call to
these functions hang.

This patch must be backported as far as 2.4.

src/hlua.c

index b5465e8b8ee120e4c0d03948899dc94bb1ea3248..f34f7b6a0af58bb9aa479aebf3cd085fbe841d32 100644 (file)
@@ -5058,7 +5058,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) && (htx->flags & HTX_FL_EOM))
+       if (htx_is_empty(htx) && (req->flags & CF_EOI))
                stop = 1;
 
        htx_to_buf(htx, &req->buf);
@@ -5150,7 +5150,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) && (htx->flags & HTX_FL_EOM))
+       if (htx_is_empty(htx) && (req->flags & CF_EOI))
                len = 0;
 
        htx_to_buf(htx, &req->buf);