]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stream: Report write timeouts before testing the flags
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Apr 2023 16:23:15 +0000 (18:23 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 10:13:09 +0000 (12:13 +0200)
A regression was introduced when stream's timeouts were refactored. Write
timeouts are not testing is the right order. When timeous of the front SC
are handled, we must then test the read timeout on the request channel and
the write timeout on the response channel. But write timeout is tested on
the request channel instead. On the back SC, the same mix-up is performed.

We must be careful to handle timeouts before checking channel flags. To
avoid any confusions, all timeuts are handled first, on front and back SCs.
Then flags of the both channels are tested.

It is a 2.8-specific issue. No backport needed.

src/stream.c

index cbcdfefb4928cdb674a350634e7424bee048d1c1..ae92b1842539f97603cc14e56877a5d55bc9f1b2 100644 (file)
@@ -1578,6 +1578,9 @@ static void stream_handle_timeouts(struct stream *s)
 
        sc_check_timeouts(s->scf);
        channel_check_timeout(&s->req);
+       sc_check_timeouts(s->scb);
+       channel_check_timeout(&s->res);
+
        if (unlikely(!(s->scb->flags & SC_FL_SHUTW) && (s->req.flags & CF_WRITE_TIMEOUT))) {
                s->scb->flags |= SC_FL_NOLINGER;
                sc_shutw(s->scb);
@@ -1588,9 +1591,6 @@ static void stream_handle_timeouts(struct stream *s)
                        s->scf->flags |= SC_FL_NOLINGER;
                sc_shutr(s->scf);
        }
-
-       sc_check_timeouts(s->scb);
-       channel_check_timeout(&s->res);
        if (unlikely(!(s->scf->flags & SC_FL_SHUTW) && (s->res.flags & CF_WRITE_TIMEOUT))) {
                s->scf->flags |= SC_FL_NOLINGER;
                sc_shutw(s->scf);