]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: h2: try to abort closed streams as soon as possible
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Dec 2017 09:42:59 +0000 (10:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Dec 2017 20:08:41 +0000 (21:08 +0100)
The purpose here is to be able to signal receipt of RST_STREAM to
streams when they start to provide a response so that the response
can be aborted ASAP. Given that RST_STREAM immediately switches the
stream to the CLOSED state, we must check for CLOSED in addition to
the existing ERROR check.

To be backported to 1.8.

src/mux_h2.c

index 733687e7bf58799480e6bfbc38e9bed941728ce1..0c2fcdeb2f73c13421bf0e6abd8db45b2c2d0965 100644 (file)
@@ -3066,7 +3066,7 @@ static int h2_snd_buf(struct conn_stream *cs, struct buffer *buf, int flags)
                if (h2s->res.state < HTTP_MSG_BODY) {
                        total += h2s_frt_make_resp_headers(h2s, buf);
 
-                       if (h2s->st == H2_SS_ERROR)
+                       if (h2s->st >= H2_SS_ERROR)
                                break;
 
                        if (h2s->flags & H2_SF_BLK_ANY)
@@ -3075,7 +3075,7 @@ static int h2_snd_buf(struct conn_stream *cs, struct buffer *buf, int flags)
                else if (h2s->res.state < HTTP_MSG_TRAILERS) {
                        total += h2s_frt_make_resp_data(h2s, buf);
 
-                       if (h2s->st == H2_SS_ERROR)
+                       if (h2s->st >= H2_SS_ERROR)
                                break;
 
                        if (h2s->flags & H2_SF_BLK_ANY)
@@ -3102,7 +3102,7 @@ static int h2_snd_buf(struct conn_stream *cs, struct buffer *buf, int flags)
        }
 
        /* RST are sent similarly to frame acks */
-       if (h2s->st == H2_SS_ERROR) {
+       if (h2s->st >= H2_SS_ERROR) {
                cs->flags |= CS_FL_ERROR;
                if (h2s_send_rst_stream(h2s->h2c, h2s) > 0)
                        h2s->st = H2_SS_CLOSED;