]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h2: fix two half-closed to closed transitions
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Jan 2019 18:28:32 +0000 (19:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Jan 2019 18:34:40 +0000 (19:34 +0100)
When receiving a HEADERS or DATA frame with END_STREAM set, we would
inconditionally switch to half-closed(remote). This is wrong because we
could already have been in half-closed(local) and need to switch to closed.
This happens in the following situations :
    - receipt of the end of a client upload after we've already responded
      (e.g. redirects to POST requests)
    - receipt of a response on the backend side after we've already finished
      sending the request (most common case).

This may possibly have caused some streams to stay longer than needed
at the end of a transfer, though this is not apparent in tests.

This must be backported to 1.9 and 1.8.

src/mux_h2.c

index 49e206832576e911f20d9722905ebd90aaeb4821..35bdd173ddeadaac270fdd641426cabab3e4b111 100644 (file)
@@ -1980,7 +1980,10 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s)
                h2s->flags |= H2_SF_ES_RCVD;
 
        if (h2s->flags & H2_SF_ES_RCVD) {
-               h2s->st = H2_SS_HREM;
+               if (h2s->st == H2_SS_OPEN)
+                       h2s->st = H2_SS_HREM;
+               else
+                       h2s_close(h2s);
                h2s->cs->flags |= CS_FL_REOS;
        }
 
@@ -2129,7 +2132,11 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s)
 
        /* last frame */
        if (h2c->dff & H2_F_DATA_END_STREAM) {
-               h2s->st = H2_SS_HREM;
+               if (h2s->st == H2_SS_OPEN)
+                       h2s->st = H2_SS_HREM;
+               else
+                       h2s_close(h2s);
+
                h2s->flags |= H2_SF_ES_RCVD;
                h2s->cs->flags |= CS_FL_REOS;