]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: centralize the check for the half-closed(remote) streams
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Oct 2017 11:03:50 +0000 (12:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:16:19 +0000 (18:16 +0100)
RFC7540#5.1 is pretty clear : "any frame other than WINDOW_UPDATE,
PRIORITY, or RST_STREAM in this state MUST be treated as a connection
error of type STREAM_CLOSED". Instead of dealing with this for each
and every frame type, let's do it once for all in the main demux loop.

src/mux_h2.c

index 5281952240c040f9668a5a90e2493580a89560be..2f7d4d72d3f6334ff1e7bae3bcf477f339165c06 100644 (file)
@@ -1613,6 +1613,15 @@ static void h2_process_demux(struct h2c *h2c)
                        break;
                }
 
+               if (h2s->st == H2_SS_HREM && h2c->dft != H2_FT_WINDOW_UPDATE &&
+                   h2c->dft != H2_FT_RST_STREAM && h2c->dft != H2_FT_PRIORITY) {
+                       /* RFC7540#5.1: any frame other than WU/PRIO/RST in
+                        * this state MUST be treated as a stream error
+                        */
+                       h2s_error(h2s, H2_ERR_STREAM_CLOSED);
+                       goto strm_err;
+               }
+
                switch (h2c->dft) {
                case H2_FT_SETTINGS:
                        if (h2c->st0 == H2_CS_FRAME_P)
@@ -1679,6 +1688,7 @@ static void h2_process_demux(struct h2c *h2c)
                        ret = h2c->dfl == 0;
                }
 
+       strm_err:
                /* RST are sent similarly to frame acks */
                if (h2s->st == H2_SS_ERROR) {
                        if (h2c->st0 == H2_CS_FRAME_P)