]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream-int: update the endp polling status only at the end of si_cs_recv()
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Nov 2018 15:55:14 +0000 (16:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Nov 2018 20:41:47 +0000 (21:41 +0100)
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

index cb73900e56d5f39e429a5a4990393e4292fa1a62..e23a283897b7e63b956eecd67f3653f324ff861d 100644 (file)
@@ -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);