Mercurial > hg > nginx
diff src/http/v2/ngx_http_v2.c @ 6783:9027991e2f37
HTTP/2: limited maximum number of requests in connection.
The new directive "http2_max_requests" is introduced. From users point of
view it works quite similar to "keepalive_requests" but has significantly
bigger default value that is more suitable for HTTP/2.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Mon, 31 Oct 2016 16:33:02 +0300 |
parents | 5e95b9fb33b7 |
children | 727c6412673a |
line wrap: on
line diff
--- a/src/http/v2/ngx_http_v2.c Thu Oct 27 17:57:16 2016 +0300 +++ b/src/http/v2/ngx_http_v2.c Mon Oct 31 16:33:02 2016 +0300 @@ -326,16 +326,21 @@ if (c->close) { c->close = 0; - h2c->goaway = 1; - - if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) == NGX_ERROR) { - ngx_http_v2_finalize_connection(h2c, 0); - return; - } - - if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { - ngx_http_v2_finalize_connection(h2c, 0); - return; + + if (!h2c->goaway) { + h2c->goaway = 1; + + if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) + == NGX_ERROR) + { + ngx_http_v2_finalize_connection(h2c, 0); + return; + } + + if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) { + ngx_http_v2_finalize_connection(h2c, 0); + return; + } } h2c->blocked = 0; @@ -1177,6 +1182,15 @@ ngx_http_v2_set_dependency(h2c, node, depend, excl); } + if (h2c->connection->requests >= h2scf->max_requests) { + h2c->goaway = 1; + + if (ngx_http_v2_send_goaway(h2c, NGX_HTTP_V2_NO_ERROR) == NGX_ERROR) { + return ngx_http_v2_connection_error(h2c, + NGX_HTTP_V2_INTERNAL_ERROR); + } + } + return ngx_http_v2_state_header_block(h2c, pos, end); rst_stream: