From d94f877cdf398282d40d1eeeb6d6c603290c4f94 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 17 Dec 2018 13:21:02 +0100 Subject: [PATCH] BUG/MINOR: mux_pt: Set CS_FL_WANT_ROOM when count is zero in rcv_buf() callback When count is zero in the function mux_pt_rcv_buf(), it means the channel's buffer is full. So we need to set the CS_FL_WANT_ROOM on the conn_stream. Otherwise, while the channel is full, we will try to receive in loop more data. --- src/mux_pt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mux_pt.c b/src/mux_pt.c index 0a2b805c3d..4d3303ac04 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -209,7 +209,7 @@ static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode) { if (cs->flags & CS_FL_SHR) return; - cs->flags &= ~CS_FL_RCV_MORE; + cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM); if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutr) cs->conn->xprt->shutr(cs->conn, (mode == CS_SHR_DRAIN)); if (cs->flags & CS_FL_SHW) @@ -246,19 +246,19 @@ static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t size_t ret; if (!count) { - cs->flags |= CS_FL_RCV_MORE; + cs->flags |= (CS_FL_RCV_MORE | CS_FL_WANT_ROOM); return 0; } b_realign_if_empty(buf); ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count, flags); if (conn_xprt_read0_pending(cs->conn)) { if (ret == 0) - cs->flags &= ~CS_FL_RCV_MORE; + cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM); cs->flags |= CS_FL_EOS; } if (cs->conn->flags & CO_FL_ERROR) { if (ret == 0) - cs->flags &= ~CS_FL_RCV_MORE; + cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM); cs->flags |= CS_FL_ERROR; } return ret;