BUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before
When dealing with a server's H2 response, we used to set the
end-of-stream flag on the conn_stream and the stream before parsing
the response, which is incorrect since we can fail to process this
response by lack of room, buffer or anything. The extend of this problem
is still limited to a few rare cases, but with trailers it will cause a
systematic failure.
This fix must be backported to 1.9.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 0c65bba..1b240a9 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1954,11 +1954,6 @@
if (b_data(&h2c->dbuf) < h2c->dfl && !b_full(&h2c->dbuf))
return NULL; // incomplete frame
- if (h2c->dff & H2_F_HEADERS_END_STREAM) {
- h2s->flags |= H2_SF_ES_RCVD;
- h2s->cs->flags |= CS_FL_REOS;
- }
-
if (!h2c_decode_headers(h2c, &h2s->rxbuf, &h2s->flags))
return NULL;
@@ -1970,6 +1965,11 @@
h2c->st0 = H2_CS_FRAME_E;
}
+ if (h2c->dff & H2_F_HEADERS_END_STREAM) {
+ h2s->flags |= H2_SF_ES_RCVD;
+ h2s->cs->flags |= CS_FL_REOS;
+ }
+
if (h2s->cs->flags & CS_FL_ERROR && h2s->st < H2_SS_ERROR)
h2s->st = H2_SS_ERROR;
else if (h2s->cs->flags & CS_FL_REOS && h2s->st == H2_SS_OPEN)