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.
This commit is contained in:
Christopher Faulet 2019-11-20 16:42:00 +01:00
parent 6db8a2e021
commit e6d8cb1e91
1 changed files with 9 additions and 5 deletions

View File

@ -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;
}
/*