BUG/MEDIUM: stconn: Fix abort on close when a large buffer is used

When a large buffer is used on a channel, once we've started to send data to
the opposite side, receives are blocked temporarily to be sure to flush the
large buffer ASAP to be able to fall back on regular buffers. This was
performed by skipping call to the endpoint (connection or applet). Howerver,
doing so, this broken the abortonclose and more generally this masked any
shut or error events reported by the lower layer.

To fix the issue, instead of skipping receives, we now try a receive but
with a requested size set to 0.

No backport needed
This commit is contained in:
Christopher Faulet 2026-03-13 09:06:43 +01:00
parent b3be3b94a0
commit cd91838042

View File

@ -1149,10 +1149,6 @@ int sc_conn_recv(struct stconn *sc)
if (!sc_alloc_ibuf(sc, &(__sc_strm(sc)->buffer_wait)))
goto end_recv;
if ((ic->flags & CF_WROTE_DATA) && b_size(sc_ib(sc)) > global.tune.bufsize) {
sc_need_room(sc, -1);
goto done_recv;
}
/* For an HTX stream, if the buffer is stuck (no output data with some
* input data) and if the HTX message is fragmented or if its free space
* wraps, we force an HTX deframentation. It is a way to have a
@ -1194,6 +1190,8 @@ int sc_conn_recv(struct stconn *sc)
* SE_FL_RCV_MORE on the SC if more space is needed.
*/
max = channel_recv_max(ic);
if ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc)))
max = 0;
ret = CALL_MUX_WITH_RET(conn->mux, rcv_buf(sc, &ic->buf, max, cur_flags));
if (sc_ep_test(sc, SE_FL_WANT_ROOM)) {
@ -1838,11 +1836,6 @@ int sc_applet_recv(struct stconn *sc)
if (!sc_alloc_ibuf(sc, &appctx->buffer_wait))
goto end_recv;
if ((ic->flags & CF_WROTE_DATA) && b_size(sc_ib(sc)) > global.tune.bufsize) {
sc_need_room(sc, -1);
goto done_recv;
}
/* For an HTX stream, if the buffer is stuck (no output data with some
* input data) and if the HTX message is fragmented or if its free space
* wraps, we force an HTX deframentation. It is a way to have a
@ -1868,6 +1861,8 @@ int sc_applet_recv(struct stconn *sc)
* SE_FL_RCV_MORE on the SC if more space is needed.
*/
max = channel_recv_max(ic);
if ((ic->flags & CF_WROTE_DATA) && b_is_large(sc_ib(sc)))
max = 0;
ret = appctx_rcv_buf(sc, &ic->buf, max, flags);
if (sc_ep_test(sc, SE_FL_WANT_ROOM)) {
/* SE_FL_WANT_ROOM must not be reported if the channel's