]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-h1: Don't subscribe for receives once read0 or error received
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 14:17:36 +0000 (16:17 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 17:10:27 +0000 (19:10 +0200)
In h1_rcv_buf(), we no longer subscribe for reads once a read0 or an error
was received. Nothing can be read anymore, and the subscription itself is
useless. In addition, since the socket remains readable at EOF, the
connection could theoretically be woken up again and again, waking the
stream up in turn, which would make the process spin until the server
responds. No reliable reproducer was found for this, but it is safer to
not subscribe for reads when no more data can ever be received.

This patch could be backported to all supported versions.

src/mux_h1.c

index 14dcea35d095f4fc57aae67666923e0492c9b67f..108ba8bcc56d822679d71fa17d793a71bceb453a 100644 (file)
@@ -5003,7 +5003,8 @@ static size_t h1_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
                TRACE_STATE("Block xprt rcv_buf to flush stream's buffer (want_fastfwd)", H1_EV_STRM_RECV, h1c->conn, h1s);
        }
        else {
-               if (((flags & CO_RFL_KEEP_RECV) || (h1m->state != H1_MSG_DONE)) && !(h1c->wait_event.events & SUB_RETRY_RECV))
+               if (((flags & CO_RFL_KEEP_RECV) || (h1m->state != H1_MSG_DONE)) && !(h1c->wait_event.events & SUB_RETRY_RECV) &&
+                   !(h1c->flags & (H1C_F_EOS|H1C_F_ERROR)))
                        h1c->conn->xprt->subscribe(h1c->conn, h1c->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
        }