BUG/MEDIUM: mux-h2: Be able to detect connection error during handshake
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Mar 2023 10:16:53 +0000 (12:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Mar 2023 12:52:42 +0000 (14:52 +0200)
commit21fb6bdab4d1924748d4c0541c3badb353d5a819
treeaba3cc6cbeb60c34f7a9ec3920e89bdabfac912e
parent41a454da0a47e0d37e37f2d9a13712b7736e9cc5
BUG/MEDIUM: mux-h2: Be able to detect connection error during handshake

When a backend H2 connection is waiting the connection is fully established,
nothing is sent. However, it remains useful to detect connection error at
this stage. It is especially important to release H2 connection on connect
error. Be able to set H2_CF_ERR_PENDiNG or H2_CF_ERROR flags when the
underlying connection is not fully established will exclude the H2C to be
inserted in a idle list in h2_detach().

Without this fix, an H2C in PREFACE state and relying on a connection in
error can be inserted in the safe list. Of course, it will be purged if not
reused. But in the mean time, it can be reused. When this happens, the
connection remains in error and nothing happens. At the end a connection
error is returned to the client. On low traffic, we can imagine a scenario
where this dead connection is the only idle connection. If it is always
reused before being purged, no connection to the server is possible.

In addition, h2c_is_dead() is updated to declare as dead any H2 connection
with a pending error if its state is PREFACE or SETTINGS1 (thus if no
SETTINGS frame was received yet).

This patch should fix the issue #2092. It must be backported as far as 2.6.
src/mux_h2.c