From dd5621ab809474675bef7bf435b931e583238fad Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 15 Nov 2018 16:55:14 +0100 Subject: [PATCH] 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. --- src/stream_interface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stream_interface.c b/src/stream_interface.c index cb73900e5..e23a28389 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1136,8 +1136,6 @@ int si_cs_recv(struct conn_stream *cs) if (cs->flags & CS_FL_EOS) 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) && global.tune.idle_timer && @@ -1236,7 +1234,6 @@ int si_cs_recv(struct conn_stream *cs) si_cant_put(si); if (ret <= 0) { - si_rx_endp_done(si); break; } @@ -1343,8 +1340,12 @@ int si_cs_recv(struct conn_stream *cs) goto out_shutdown_r; /* 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); + si_rx_endp_done(si); + } else { + si_rx_endp_more(si); + } return (cur_read != 0) || si_rx_blocked(si);