Skip to content

Commit 1ed4ef6

Browse files
committed
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.
1 parent 3fab21e commit 1ed4ef6

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/applet.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,6 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig
539539
if (applet_fl_test(appctx, APPCTX_FL_OUTBLK_ALLOC))
540540
goto end;
541541

542-
if (!count)
543-
goto end;
544-
545542
if (!appctx_get_buf(appctx, &appctx->outbuf)) {
546543
TRACE_STATE("waiting for appctx outbuf allocation", APPLET_EV_RECV|APPLET_EV_BLK, appctx);
547544
goto end;
@@ -550,7 +547,8 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig
550547
if (flags & CO_RFL_BUF_FLUSH)
551548
applet_fl_set(appctx, APPCTX_FL_FASTFWD);
552549

553-
ret = CALL_APPLET_WITH_RET(appctx->applet, rcv_buf(appctx, buf, count, flags));
550+
if (count)
551+
ret = CALL_APPLET_WITH_RET(appctx->applet, rcv_buf(appctx, buf, count, flags));
554552
if (ret)
555553
applet_fl_clr(appctx, APPCTX_FL_OUTBLK_FULL);
556554

0 commit comments

Comments
 (0)