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 43248f2..4c580c4 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -2335,14 +2335,15 @@
* 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 @@
* 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;
}