]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: send RST_STREAM before GOAWAY on reject
authorWilly Tarreau <w@1wt.eu>
Fri, 24 Nov 2017 07:00:30 +0000 (08:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Nov 2017 07:00:30 +0000 (08:00 +0100)
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.

src/mux_h2.c

index 43248f2cb4d2ec4f1205a6c160981533827dbf74..4c580c4a8683de4c7e73aaf32a377aa6725da56d 100644 (file)
@@ -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;
        }