]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stconn: Forward shutdown on write timeout only if it is forwardable
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jan 2024 15:48:40 +0000 (16:48 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jan 2024 16:28:06 +0000 (17:28 +0100)
The commit b9c87f8082 ("BUG/MEDIUM: stconn/stream: Forward shutdown on write
timeout") introduced a regression. In sc_cond_forward_shut(), the write
timeout is considered too early to forward the shutdown. In fact, it is
always considered, even if the shutdown is not forwardable yet. It is of
course unexpected. It is especially an issue when a write timeout is
encountered on server side during the connection establishment. In this
case, if shutdown is forwarded too early on the client side, the connection
is closed before the 503 error sending.

So the write timeout must indeed be considered to forward the shutdown to
the underlying layer, but only if the shutdown is forwardable. Otherwise, we
should do nothing.

This patch should fix the issue #2404. It must be backported as far as 2.2.

src/stconn.c

index b3aed9521f9e4c2cf900f0b4a615f1f426e5a0e6..74efca7efd38a9e3d72d439b6530a9b01e641dc9 100644 (file)
@@ -522,15 +522,11 @@ struct appctx *sc_applet_create(struct stconn *sc, struct applet *app)
  */
 static inline int sc_cond_forward_shut(struct stconn *sc)
 {
-       /* Forward the shutdown if an write error occurred on the input channel */
-       if (sc_ic(sc)->flags & CF_WRITE_TIMEOUT)
-               return 1;
-
        /* The close must not be forwarded */
        if (!(sc->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) || !(sc->flags & SC_FL_NOHALF))
                return 0;
 
-       if (co_data(sc_ic(sc))) {
+       if (co_data(sc_ic(sc)) && !(sc_ic(sc)->flags & CF_WRITE_TIMEOUT)) {
                /* the shutdown cannot be forwarded now because
                 * we should flush outgoing data first. But instruct the output
                 * channel it should be done ASAP.