MINOR: h2: centralize the check for the half-closed(remote) streams

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.
This commit is contained in:
Willy Tarreau 2017-10-30 12:03:50 +01:00
parent f65b80dd47
commit f182a9a8b4

View 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)