]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h2: make it possible to set the error code on an already closed stream
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Jan 2019 09:02:24 +0000 (10:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Jan 2019 14:27:06 +0000 (15:27 +0100)
When sending RST_STREAM in response to a frame delivered on an already
closed stream, we used not to be able to update the error code and
deliver an RST_STREAM with a wrong code (e.g. H2_ERR_CANCEL). Let's
always allow to update the code so that RST_STREAM is always sent
with the appropriate error code (most often H2_ERR_STREAM_CLOSED).

This should be backported to 1.9 and possibly to 1.8.

src/mux_h2.c

index 6ec53e88f75d83cf58826541cb17591a77637ac2..be301835cb0ba0bcdd4017b7bb68716b5db47116 100644 (file)
@@ -616,12 +616,15 @@ static inline __maybe_unused void h2c_error(struct h2c *h2c, enum h2_err err)
        h2c->st0 = H2_CS_ERROR;
 }
 
-/* marks an error on the stream */
+/* marks an error on the stream. It may also update an already closed stream
+ * (e.g. to report an error after an RST was received).
+ */
 static inline __maybe_unused void h2s_error(struct h2s *h2s, enum h2_err err)
 {
-       if (h2s->id && h2s->st < H2_SS_ERROR) {
+       if (h2s->id && h2s->st != H2_SS_ERROR) {
                h2s->errcode = err;
-               h2s->st = H2_SS_ERROR;
+               if (h2s->st < H2_SS_ERROR)
+                       h2s->st = H2_SS_ERROR;
                if (h2s->cs)
                        cs_set_error(h2s->cs);
        }