From: Christopher Faulet Date: Thu, 9 Sep 2021 08:17:59 +0000 (+0200) Subject: BUG/MEDIUM: stream-int: Don't block SI on a channel policy if EOI is reached X-Git-Tag: v2.5-dev7~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=883d83e83c54c77cd16735716a029670b6317926;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: stream-int: Don't block SI on a channel policy if EOI is reached If the end of input is reported by the mux on the conn-stream during a receive, we leave without evaluating the channel policies. It is especially important to be able to catch client aborts during server connection establishment. Indeed, in this case, without this patch, the stream-interface remains blocked and read events are not forwarded to the stream. It means it is not possible to detect client aborts. Thanks to this fix, the abortonclose option should fixed for HAProxy 2.3 and lower. On 2.4 and 2.5, it seems to work because the stream is created after the request parsing. Note that a previous fix of abortonclose option was reverted. This one should be the right way to fix it. It must carefully be backported as far as 2.0. A observation period on the 2.3 is probably a good idea. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index 16c3dbcca7..68b89525e3 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1381,6 +1381,14 @@ int si_cs_recv(struct conn_stream *cs) ic->flags |= CF_READ_PARTIAL; ic->total += ret; + /* End-of-input reached, we can leave. In this case, it is + * important to break the loop to not block the SI because of + * the channel's policies.This way, we are still able to receive + * shutdowns. + */ + if (cs->flags & CS_FL_EOI) + break; + if ((ic->flags & CF_READ_DONTWAIT) || --read_poll <= 0) { /* we're stopped by the channel's policy */ si_rx_chan_blk(si);