]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h2: send a GOAWAY frame when dealing with an empty response
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 06:41:55 +0000 (07:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 17:16:19 +0000 (18:16 +0100)
Given that we're processing data produced by haproxy, we know that the
situations where haproxy doesn't return anything are :
  - request timeout with option http-ignore-probes : there's no reason to
    hit this since we're creating the stream with the request into it ;

  - tcp-request content reject : this definitely means we want to kill the
    connection and abort keep-alive and any further processing ;

  - using /dev/null as the error file to hide an error

In practice it appears that using the abort on empty response as a hint to
trigger a connection close is very appropriate to continue to give the
control over the connection management. This patch thus tries to send a
GOAWAY frame with the max_id presented as the last stream ID, then sends
an RST_STREAM for the current stream. For the client, this means that the
connection must be shut down immediately after processing the last pending
streams and that the current stream is aborted. This way it's still possible
to force connections to be closed using tcp-request rules.

src/mux_h2.c

index 28eb5d802c0cb2750d343de60b17b4ab9807bc5d..07800522e7abbe7f117e1ca4f567637916911228 100644 (file)
@@ -2168,6 +2168,14 @@ static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
                if (h2_send_empty_data_es(h2s) <= 0)
                        return;
        } else {
+               /* let's signal a wish to close the connection if no headers
+                * were seen as this usually means it's a tcp-request rule which
+                * has aborted the response.
+                */
+               if (!(h2s->h2c->flags & (H2_CF_GOAWAY_SENT|H2_CF_GOAWAY_FAILED)) &&
+                   h2c_send_goaway_error(h2s->h2c, h2s) <= 0)
+                       return;
+
                if (h2c_send_rst_stream(h2s->h2c, h2s) <= 0)
                        return;
        }