]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: make sure we always have a timeout on front connections
authorWilly Tarreau <w@1wt.eu>
Tue, 28 Apr 2020 17:48:41 +0000 (19:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 Apr 2020 17:48:41 +0000 (19:48 +0200)
Mux-h1 currently heavily relies on the presence of an upper stream, even
when waiting for a new request after one is being finished, and it's that
upper stream that's in charge of request and keep-alive timeouts for now.
But since recent commit 493d9dc6ba ("MEDIUM: mux-h1: do not blindly wake
up the tasklet at end of request anymore") that assumption was broken as
the purpose of this change was to avoid initiating processing of a request
when there's no data in the buffer. The side effect is that there's no more
timeout to handle the front connection, resulting in dead front connections
stacking up as clients get kicked off the net.

This fix makes sure we always enable the timeout when there's no stream
attached to the connection. It doesn't do this for back connections since
they may purposely be left idle.

No backport is needed as this bug was introduced in 2.2-dev4.

src/mux_h1.c

index 7eaf8ccae6b568976dab90285195dc192d957bea..0421bbad54ba7031bffc056b70ec8bdf666165a0 100644 (file)
@@ -2498,7 +2498,10 @@ static void h1_detach(struct conn_stream *cs)
                        h1c->conn->xprt->subscribe(h1c->conn, h1c->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
                if (h1c->task) {
                        h1c->task->expire = TICK_ETERNITY;
-                       if (b_data(&h1c->obuf)) {
+                       if ((!h1c->h1s && !conn_is_back(h1c->conn)) || b_data(&h1c->obuf)) {
+                               /* front connections waiting for a stream, as well as any connection with
+                                * pending data, need a timeout.
+                                */
                                h1c->task->expire = tick_add(now_ms, ((h1c->flags & (H1C_F_CS_SHUTW_NOW|H1C_F_CS_SHUTDOWN))
                                                                      ? h1c->shut_timeout
                                                                      : h1c->timeout));