]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: Set CO_RFL transient/persistent flags apart in si_cs_rcv()
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Sep 2021 13:14:57 +0000 (15:14 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Sep 2021 14:19:36 +0000 (16:19 +0200)
In si_cs_recv(), some CO_RFL flags are set when the mux's .rcv_buf()
function is called. Some are persitent inside si_cs_recv() scope, some
others must be computed at each call to rcv_buf(). This patch takes care of
distinguishing them.

Among others, CO_RFL_KEEP_RECV is a persistent flag while CO_RFL_BUF_WET is
transient.

src/stream_interface.c

index e5da8ea56534ad091d8caee351b53820350e3b8c..23070ba192dbeecb66ab438ba9103f46e4d6db1d 100644 (file)
@@ -1336,6 +1336,10 @@ int si_cs_recv(struct conn_stream *cs)
        if (!si_alloc_ibuf(si, &(si_strm(si)->buffer_wait)))
                goto end_recv;
 
+
+       /* Instruct the mux it must subscribed for read events */
+       flags |= ((!conn_is_back(conn) && (si_strm(si)->be->options & PR_O_ABRT_CLOSE)) ? CO_RFL_KEEP_RECV : 0);
+
        /* Important note : if we're called with POLL_IN|POLL_HUP, it means the read polling
         * was enabled, which implies that the recv buffer was not full. So we have a guarantee
         * that if such an event is not handled above in splice, it will be handled here by
@@ -1344,12 +1348,17 @@ int si_cs_recv(struct conn_stream *cs)
        while ((cs->flags & CS_FL_RCV_MORE) ||
            (!(conn->flags & (CO_FL_ERROR | CO_FL_HANDSHAKE)) &&
               (!(cs->flags & (CS_FL_ERROR|CS_FL_EOS))) && !(ic->flags & CF_SHUTR))) {
+               int cur_flags = flags;
+
+               /* Compute transient CO_RFL_* flags */
+               if (co_data(ic))
+                       cur_flags |= CO_RFL_BUF_WET;
+
                /* <max> may be null. This is the mux responsibility to set
                 * CS_FL_RCV_MORE on the CS if more space is needed.
                 */
                max = channel_recv_max(ic);
-               flags |= ((!conn_is_back(conn) && (si_strm(si)->be->options & PR_O_ABRT_CLOSE)) ? CO_RFL_KEEP_RECV : 0);
-               ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, flags | (co_data(ic) ? CO_RFL_BUF_WET : 0));
+               ret = cs->conn->mux->rcv_buf(cs, &ic->buf, max, cur_flags);
 
                if (cs->flags & CS_FL_WANT_ROOM) {
                        si_rx_room_blk(si);