MEDIUM: stream-int: update the endp polling status only at the end of si_cs_recv()

Instead of first indicating that there's more data to read from the
conn_stream then re-adjusting this info along the function, we now
instead set the status according to the subscription status at the
end. It's easier, more accurate, and less sensitive to intermediary
changes.

This will soon allow to remove all the si_cant_put() calls that were
placed in the middle to force a subsequent callback and prevent the
function from subscribing to the mux layer.
This commit is contained in:
Willy Tarreau 2018-11-15 16:55:14 +01:00
parent 8bb2ffb831
commit dd5621ab80

View File

@ -1136,8 +1136,6 @@ int si_cs_recv(struct conn_stream *cs)
if (cs->flags & CS_FL_EOS) if (cs->flags & CS_FL_EOS)
goto out_shutdown_r; goto out_shutdown_r;
/* start by claiming we'll want to receive and change our mind later if needed */
si_rx_endp_more(si);
if ((ic->flags & (CF_STREAMER | CF_STREAMER_FAST)) && !co_data(ic) && if ((ic->flags & (CF_STREAMER | CF_STREAMER_FAST)) && !co_data(ic) &&
global.tune.idle_timer && global.tune.idle_timer &&
@ -1236,7 +1234,6 @@ int si_cs_recv(struct conn_stream *cs)
si_cant_put(si); si_cant_put(si);
if (ret <= 0) { if (ret <= 0) {
si_rx_endp_done(si);
break; break;
} }
@ -1343,8 +1340,12 @@ int si_cs_recv(struct conn_stream *cs)
goto out_shutdown_r; goto out_shutdown_r;
/* Subscribe to receive events if we're blocking on I/O */ /* Subscribe to receive events if we're blocking on I/O */
if (!si_rx_blocked(si)) if (!si_rx_blocked(si)) {
conn->mux->subscribe(cs, SUB_CAN_RECV, &si->wait_event); conn->mux->subscribe(cs, SUB_CAN_RECV, &si->wait_event);
si_rx_endp_done(si);
} else {
si_rx_endp_more(si);
}
return (cur_read != 0) || si_rx_blocked(si); return (cur_read != 0) || si_rx_blocked(si);