]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stream-int: Fix si_cs_recv() return value
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Nov 2019 15:42:00 +0000 (16:42 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 20 Nov 2019 15:48:01 +0000 (16:48 +0100)
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

index 9503d12f65cacf530c09d4739b23f98f7332288e..e673e0f5a535be66c8e8d455911cde927078e70a 100644 (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;
 }
 
 /*