Skip to content

Commit

Permalink
BUG/MAJOR: mux-h1: Wake SC to perform 0-copy forwarding in CLOSING state
Browse files Browse the repository at this point in the history
When the mux is woken up on I/O events, if the zero-copy forwarding is
enabled, receives are blocked. In this case, the SC is woken up to be able
to perform 0-copy forwarding to the other side. This works well, except for
the H1C in CLOSING state.

Indeed, in that case, in h1_process(), the SC is not woken up because only
RUNNING H1 connections are considered. As consequence, the mux will ignore
connection closure. The H1 connection remains blocked, waiting for the
shutdown timeout. If no timeout is configured, the H1 connection is never
closed leading to a leak.

This patch should fix leak reported by Damien Claisse in the issue haproxy#2697. It
should be backported as far as 2.8.

(cherry picked from commit f6e193f)
Signed-off-by: Willy Tarreau <[email protected]>
(cherry picked from commit 0be5e36)
Signed-off-by: Willy Tarreau <[email protected]>
(cherry picked from commit 3adb1a6)
[wt: minor ctx adj: flag was WANT_SPLICE in 2.8]
Signed-off-by: Willy Tarreau <[email protected]>
  • Loading branch information
capflam authored and wtarreau committed Sep 10, 2024
1 parent 2f33952 commit 1b53186
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mux_h1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,7 @@ static int h1_process(struct h1c * h1c)
}
}

if (h1c->state == H1_CS_RUNNING && (h1c->flags & H1C_F_WANT_SPLICE) && !h1s_data_pending(h1c->h1s)) {
if (h1c->state >= H1_CS_RUNNING && (h1c->flags & H1C_F_WANT_SPLICE) && !h1s_data_pending(h1c->h1s)) {
TRACE_DEVEL("xprt rcv_buf blocked (want_splice), notify h1s for recv", H1_EV_H1C_RECV, h1c->conn);
h1_wake_stream_for_recv(h1c->h1s);
}
Expand Down

0 comments on commit 1b53186

Please sign in to comment.