]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h2: properly consider all conditions for end of connection
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 05:59:15 +0000 (06:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:16:17 +0000 (18:16 +0100)
During h2_wake(), there are various situations that can lead to the
connection being closed :
  - low-level connection error
  - read0 received
  - fatal error (ERROR2)
  - failed to emit a GOAWAY
  - empty stream list with max_id >= last_sid

In such cases, all streams are notified and we have to wait for all
streams to leave while doing nothing, or if the last stream is gone,
we can simply terminate the connection.

It's important to do this test there again because an error might arise
while trying to send a pending GOAWAY after the last stream for example,
thus there's possibly no way to get notified of a closing stream.

src/mux_h2.c

index d69229f796bc6b40807f1f84d2079f5260fcb03b..ed891d6e103fbeed28a05b68f1e3cb19ce0722cf 100644 (file)
@@ -704,7 +704,9 @@ static int h2_wake(struct connection *conn)
        struct h2c *h2c = conn->mux_ctx;
 
        if (conn->flags & CO_FL_ERROR || conn_xprt_read0_pending(conn) ||
-           h2c->st0 == H2_CS_ERROR2) {
+           h2c->st0 == H2_CS_ERROR2 || h2c->flags & H2_CF_GOAWAY_FAILED ||
+           (eb_is_empty(&h2c->streams_by_id) && h2c->last_sid >= 0 &&
+            h2c->max_id >= h2c->last_sid)) {
                h2_wake_all_streams(h2c);
 
                if (eb_is_empty(&h2c->streams_by_id)) {