From: Willy Tarreau Date: Mon, 6 Nov 2017 19:20:51 +0000 (+0100) Subject: BUG/MINOR: h2: set the "HEADERS_SENT" flag on stream, not connection X-Git-Tag: v1.8-rc3~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6743420778e65815184e36817e5e24fe0c5b4749;p=thirdparty%2Fhaproxy.git BUG/MINOR: h2: set the "HEADERS_SENT" flag on stream, not connection This flag was added after the GOAWAY flags were introduced and mistakenly placed in the connection, but that doesn't make sense as it's specific to the stream. The main impact is the risk of returning a DATA0+ES frame for an error instead of an RST_STREAM. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index ed4027c5f1..2af5ffd630 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -54,7 +54,6 @@ static struct pool_head *pool2_h2s; /* other flags */ #define H2_CF_GOAWAY_SENT 0x00000100 // a GOAWAY frame was successfully sent #define H2_CF_GOAWAY_FAILED 0x00000200 // a GOAWAY frame failed to be sent -#define H2_CF_HEADERS_SENT 0x00000400 // a HEADERS frame was sent /* H2 connection state, in h2c->st0 */ @@ -156,6 +155,8 @@ enum h2_ss { #define H2_SF_CHNK_MASK 0x00000C00 // trying to send chunk size +#define H2_SF_HEADERS_SENT 0x00001000 // a HEADERS frame was sent for this stream + /* H2 stream descriptor, describing the stream as it appears in the H2C, and as * it is being processed in the internal HTTP representation (H1 for now). */ @@ -2252,7 +2253,7 @@ static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode) h2s->st == H2_SS_RESET || h2s->st == H2_SS_CLOSED) return; - if (h2s->h2c->flags & H2_CF_HEADERS_SENT) { + if (h2s->flags & H2_SF_HEADERS_SENT) { if (h2_send_empty_data_es(h2s) <= 0) return; } else { @@ -2675,7 +2676,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf) /* commit the H2 response */ h2c->mbuf->o += outbuf.len; h2c->mbuf->p = b_ptr(h2c->mbuf, outbuf.len); - h2c->flags |= H2_CF_HEADERS_SENT; + h2s->flags |= H2_SF_HEADERS_SENT; /* for now we don't implemented CONTINUATION, so we wait for a * body or directly end in TRL2.