]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: mux-h1: don't report a 408 error on timeout of a closed connection
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Oct 2026 09:29:35 +0000 (11:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 16 Oct 2026 17:10:27 +0000 (19:10 +0200)
When a frontend connection times out, the mux H1 tries to send a 408 error
to the client unless the connection is in the CLOSING state. But a
connection may also be in the CLOSED state, waiting the client closes on its
side. In that case too, no 408 must be emitted. Because of this issue, the
failed requests counters are incremented, a "408 <BADREQ>" log line is
emitted while it should not.

Now the error is only sent if the connection is still alive.

It should be backported as far as 2.8.

src/mux_h1.c

index 27b96e427106dab97a8bd2c99bbc55085450598b..dc50929e78bfb793b144cc8afbe755208d18efb5 100644 (file)
@@ -4656,8 +4656,10 @@ struct task *h1_timeout_task(struct task *t, void *context, unsigned int state)
                        return t;
                }
 
-               /* Try to send an error to the client */
-               if (h1c->state != H1_CS_CLOSING && !(h1c->flags & (H1C_F_IS_BACK|H1C_F_ERROR|H1C_F_ABRT_PENDING))) {
+               /* Try to send an error to the client, unless the connection is
+                * already closing or closed (i.e. shut down for writes).
+                */
+               if (h1_is_alive(h1c) && !(h1c->flags & (H1C_F_IS_BACK|H1C_F_ERROR|H1C_F_ABRT_PENDING))) {
                        TRACE_DEVEL("timeout error detected", H1_EV_H1C_WAKE|H1_EV_H1C_ERR, h1c->conn, h1c->h1s);
                        if (h1_handle_req_tout(h1c))
                                h1_send(h1c);