]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua: Properly enable/disable line receives from HTTP applet
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 2 Mar 2026 18:07:07 +0000 (19:07 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Mar 2026 14:34:46 +0000 (15:34 +0100)
From a lua HTTP applet, in the getline() function, we must take care to
disable receives when a line is retrieved and to restart receives when the
function is called again. In addition, when an applet execution is finished,
we must restart receives to properly drain the request.

This patch could help to fix #3293. It must be backported to 3.3. On older
version, no bug was reported so we can wait a report first. But in that
case, hlua_applet_http_recv() should also be fixed (on 3.3 it was fixed
during the applets refactoring).

src/hlua.c

index 764c0fb84a4ce92c2872dd56b8d88f2295088083..a31ada50fa2c71385002f1732e542e579c714aae 100644 (file)
@@ -5833,6 +5833,9 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
                MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_getline_yield, TICK_ETERNITY, 0));
        }
 
+       /* Stop to consume until the next receive or the end of the response */
+       applet_wont_consume(luactx->appctx);
+
        /* return the result. */
        luaL_pushresult(&luactx->b);
        return 1;
@@ -5844,6 +5847,9 @@ __LJMP static int hlua_applet_http_getline(lua_State *L)
 {
        struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
 
+       /* Restart to consume - could have been disabled by a previous receive */
+       applet_will_consume(luactx->appctx);
+
        /* Initialise the string catenation. */
        luaL_buffinit(L, &luactx->b);
 
@@ -11502,6 +11508,9 @@ void hlua_applet_http_fct(struct appctx *ctx)
        if (!(strm->flags & SF_ERR_MASK))
                strm->flags |= SF_ERR_RESOURCE;
        http_ctx->flags |= APPLET_DONE;
+
+       /* Restart to consume to drain the request */
+       applet_will_consume(ctx);
        goto out;
 }