From: Willy Tarreau Date: Fri, 24 Nov 2017 07:00:30 +0000 (+0100) Subject: MINOR: h2: send RST_STREAM before GOAWAY on reject X-Git-Tag: v1.8.0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c3232e54c7c0eeedb294a2ac80247a732678ac;p=thirdparty%2Fhaproxy.git MINOR: h2: send RST_STREAM before GOAWAY on reject Apparently the h2c client has trouble reading the RST_STREAM frame after a GOAWAY was sent, so it's likely that other clients may face the same difficulty. Curl and Firefox don't care about this ordering, so let's send it first. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 43248f2cb4..4c580c4a86 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2335,14 +2335,15 @@ static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode) * used to kill the connection ASAP (eg: limit abuse). In this * case we send a goaway to close the connection. */ + if (!(h2s->flags & H2_SF_RST_SENT) && + h2s_send_rst_stream(h2s->h2c, h2s) <= 0) + return; + if (!(h2s->flags & H2_SF_OUTGOING_DATA) && !(h2s->h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED)) && h2c_send_goaway_error(h2s->h2c, h2s) <= 0) return; - if (h2s_send_rst_stream(h2s->h2c, h2s) <= 0) - return; - if (h2s->h2c->mbuf->o && !(cs->conn->flags & CO_FL_XPRT_WR_ENA)) conn_xprt_want_send(cs->conn); @@ -2373,15 +2374,15 @@ static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode) * used to kill the connection ASAP (eg: limit abuse). In this * case we send a goaway to close the connection. */ + if (!(h2s->flags & H2_SF_RST_SENT) && + h2s_send_rst_stream(h2s->h2c, h2s) <= 0) + return; + if (!(h2s->flags & H2_SF_OUTGOING_DATA) && !(h2s->h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED)) && h2c_send_goaway_error(h2s->h2c, h2s) <= 0) return; - if (!(h2s->flags & H2_SF_RST_SENT) && - h2s_send_rst_stream(h2s->h2c, h2s) <= 0) - return; - h2s->st = H2_SS_CLOSED; }