]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: make HTX_BLK_EOM processing idempotent
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Jan 2019 08:28:17 +0000 (09:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 4 Jan 2019 08:28:17 +0000 (09:28 +0100)
We want to make sure we won't emit another empty DATA frame if we meet
HTX_BLK_EOM after and end of stream was already sent. For now it cannot
happen as far as HTX is respected, but with trailers it may become
ambiguous.

src/mux_h2.c

index e192cb39266ddb150cca7970aacfb6489bf1064e..4fcc339e0b70639f25084efb264afcd1fa3a16ec 100644 (file)
@@ -4563,8 +4563,16 @@ static size_t h2s_htx_frt_make_resp_data(struct h2s *h2s, struct buffer *buf, si
                count--;
                goto end;
        }
-
-       if (type != HTX_BLK_DATA && type != HTX_BLK_EOM)
+       else if (type == HTX_BLK_EOM) {
+               if (h2s->flags & H2_SF_ES_SENT) {
+                       /* ES already sent */
+                       htx_remove_blk(htx, blk);
+                       total++; // EOM counts as one byte
+                       count--;
+                       goto end;
+               }
+       }
+       else if (type != HTX_BLK_DATA)
                goto end;
 
        /* Perform some optimizations to reduce the number of buffer copies.