From: Christopher Faulet Date: Tue, 21 Sep 2021 13:14:57 +0000 (+0200) Subject: MINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv() X-Git-Tag: v2.5-dev8~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68a14db573dbcf1385ce1a70d5ca477768a61d4a;p=thirdparty%2Fhaproxy.git MINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv() In si_cs_recv(), some CO_RFL flags are set when the mux's .rcv_buf() function is called. Some are persitent inside si_cs_recv() scope, some others must be computed at each call to rcv_buf(). This patch takes care of distinguishing them. Among others, CO_RFL_KEEP_RECV is a persistent flag while CO_RFL_BUF_WET is transient. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index e5da8ea565..23070ba192 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1336,6 +1336,10 @@ int si_cs_recv(struct conn_stream *cs) if (!si_alloc_ibuf(si, &(si_strm(si)->buffer_wait))) goto end_recv; + + /* Instruct the mux it must subscribed for read events */ + flags |= ((!conn_is_back(conn) && (si_strm(si)->be->options & PR_O_ABRT_CLOSE)) ? CO_RFL_KEEP_RECV : 0); + /* Important note : if we're called with POLL_IN|POLL_HUP, it means the read polling * was enabled, which implies that the recv buffer was not full. So we have a guarantee * that if such an event is not handled above in splice, it will be handled here by @@ -1344,12 +1348,17 @@ int si_cs_recv(struct conn_stream *cs) while ((cs->flags & CS_FL_RCV_MORE) || (!(conn->flags & (CO_FL_ERROR | CO_FL_HANDSHAKE)) && (!(cs->flags & (CS_FL_ERROR|CS_FL_EOS))) && !(ic->flags & CF_SHUTR))) { + int cur_flags = flags; + + /* Compute transient CO_RFL_* flags */ + if (co_data(ic)) + cur_flags |= CO_RFL_BUF_WET; + /* may be null. This is the mux responsibility to set * CS_FL_RCV_MORE on the CS if more space is needed. */ max = channel_recv_max(ic); - flags |= ((!conn_is_back(conn) && (si_strm(si)->be->options & PR_O_ABRT_CLOSE)) ? CO_RFL_KEEP_RECV : 0); - ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, flags | (co_data(ic) ? CO_RFL_BUF_WET : 0)); + ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, cur_flags); if (cs->flags & CS_FL_WANT_ROOM) { si_rx_room_blk(si);