From 1ed4ef6659268c1b257d2640308dbd8367a31695 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 21 May 2026 16:16:04 +0200 Subject: [PATCH] BUG/MEDIUM: applet: Properly handle receives of size 0 when appctx_rcv_buf() function was called to get data from the applet, but to get zero bytes, nothing was performed and the function early returned. However, we must at least take care to set SE_FL_WANT_ROOM if necessary. Otherwise, if data are still blocked in the applet's output buffer while the EOI/EOS are pending, the information can be reported to the upper layer and remaining data can be lost. Indeed, in such case, SE_FL_WANT_ROOM flag is here to specify the applet has more data to deliver. Thanks to this flag, the stream will wait before closing. But when appctx_rcv_buf() function is called, this flag is removed by the stconn. It is the function responsibility to set it again when necessary. This patch should fix second part of the issue #3366. It must be backported to 3.0. --- src/applet.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/applet.c b/src/applet.c index e1ec9b837..d93720ec9 100644 --- a/src/applet.c +++ b/src/applet.c @@ -539,9 +539,6 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC)) goto end; - if (!count) - goto end; - if (!appctx_get_buf(appctx, &appctx->outbuf)) { TRACE_STATE("waiting for appctx outbuf allocation", APPLET_EV_RECV|APPLET_EV_BLK, appctx); goto end; @@ -550,7 +547,8 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig if (flags & CO_RFL_BUF_FLUSH) applet_fl_set(appctx, APPCTX_FL_FASTFWD); - ret = CALL_APPLET_WITH_RET(appctx->applet, rcv_buf(appctx, buf, count, flags)); + if (count) + ret = CALL_APPLET_WITH_RET(appctx->applet, rcv_buf(appctx, buf, count, flags)); if (ret) applet_fl_clr(appctx, APPCTX_FL_OUTBLK_FULL);