From: Christopher Faulet Date: Mon, 21 Feb 2022 15:12:00 +0000 (+0100) Subject: DEBUG: stream-int: Check CS_FL_WANT_ROOM is not set with an empty input buffer X-Git-Tag: v2.6-dev2~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae17925b87fac8057917125639726685c8a82d20;p=thirdparty%2Fhaproxy.git DEBUG: stream-int: Check CS_FL_WANT_ROOM is not set with an empty input buffer In si_cs_recv(), the mux must never set CS_FL_WANT_ROOM flag on the conn-stream if the input buffer is empty and nothing was copied. It is important because, there is nothing the app layer can do in this case to make some room. If this happens, this will most probably lead to a ping-pong loop between the mux and the stream. With this BUG_ON(), it will be easier to spot such bugs. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index b78c3bc48e..c32d566c5f 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1377,6 +1377,11 @@ int si_cs_recv(struct conn_stream *cs) ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, cur_flags); if (cs->flags & CS_FL_WANT_ROOM) { + /* CS_FL_WANT_ROOM must not be reported if the channel's + * buffer is empty. + */ + BUG_ON(c_empty(ic)); + si_rx_room_blk(si); /* Add READ_PARTIAL because some data are pending but * cannot be xferred to the channel