diff --git a/src/mux_h1.c b/src/mux_h1.c index bd7d03835..7031d533f 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1667,6 +1667,7 @@ static int h1_recv(struct h1c *h1c) int aligned = 0; h1c->flags &= ~H1C_F_IN_FULL; + b_realign_if_empty(&h1c->ibuf); if (!b_data(&h1c->ibuf)) { /* try to pre-align the buffer like the rxbufs will be * to optimize memory copies. diff --git a/src/mux_h2.c b/src/mux_h2.c index 807f3197d..2e3753d7c 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2446,6 +2446,7 @@ static int h2_recv(struct h2c *h2c) do { int aligned = 0; + b_realign_if_empty(buf); if (!b_data(buf) && (h2c->proxy->options2 & PR_O2_USE_HTX)) { /* HTX in use : try to pre-align the buffer like the * rxbufs will be to optimize memory copies. We'll make diff --git a/src/mux_pt.c b/src/mux_pt.c index 94824193a..af6967631 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -249,6 +249,7 @@ static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t cs->flags |= CS_FL_RCV_MORE; return 0; } + b_realign_if_empty(buf); ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count, flags); if (conn_xprt_read0_pending(cs->conn)) { if (ret == 0) diff --git a/src/raw_sock.c b/src/raw_sock.c index df861f48d..bdbcdede0 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -276,8 +276,6 @@ static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_ } } - b_realign_if_empty(buf); - /* read the largest possible block. For this, we perform only one call * to recv() unless the buffer wraps and we exactly fill the first hunk, * in which case we accept to do it once again. A new attempt is made on diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 5fd4f4e9e..d722867da 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -5438,8 +5438,6 @@ static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_ /* a handshake was requested */ return 0; - b_realign_if_empty(buf); - /* read the largest possible block. For this, we perform only one call * to recv() unless the buffer wraps and we exactly fill the first hunk, * in which case we accept to do it once again. A new attempt is made on