From e6d8cb1e911267662c92f257f0f42df1ec78d42b Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 20 Nov 2019 16:42:00 +0100 Subject: [PATCH] BUG/MINOR: stream-int: Fix si_cs_recv() return value The previous patch on this function (36b536d6c "BUG/MEDIUM: stream-int: Don't loose events on the CS when an EOS is reported") contains a bug. The return value is based on the conn-stream's flags. But it may be reset if the CS is closed. Ironically it was exactly the purpose of this patch... This patch must be backported to 2.0 and 1.9. --- src/stream_interface.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/stream_interface.c b/src/stream_interface.c index 9503d12f65..e673e0f5a5 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1474,14 +1474,19 @@ int si_cs_recv(struct conn_stream *cs) } end_recv: + ret = (cur_read != 0); + /* Report EOI on the channel if it was reached from the mux point of * view. */ - if ((cs->flags & CS_FL_EOI) && !(ic->flags & CF_EOI)) + if ((cs->flags & CS_FL_EOI) && !(ic->flags & CF_EOI)) { ic->flags |= (CF_EOI|CF_READ_PARTIAL); + ret = 1; + } if (conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR) { cs->flags |= CS_FL_ERROR; si->flags |= SI_FL_ERR; + ret = 1; } else if (cs->flags & CS_FL_EOS) { /* connection closed */ @@ -1492,6 +1497,7 @@ int si_cs_recv(struct conn_stream *cs) channel_shutw_now(ic); stream_int_read0(si); } + ret = 1; } else if (!si_rx_blocked(si)) { /* Subscribe to receive events if we're blocking on I/O */ @@ -1499,11 +1505,9 @@ int si_cs_recv(struct conn_stream *cs) si_rx_endp_done(si); } else { si_rx_endp_more(si); + ret = 1; } - - return (cur_read != 0) || - si_rx_blocked(si) || - (cs->flags & (CS_FL_EOI|CS_FL_EOS|CS_FL_ERROR)); + return ret; } /*