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 (!h2c->goaway) {
+ h2c->goaway = 1;
- if (ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) {
- ngx_http_v2_finalize_connection(h2c, 0);
- return;
+ 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;
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:
offsetof(ngx_http_v2_srv_conf_t, concurrent_streams),
NULL },
+ { ngx_string("http2_max_requests"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_SRV_CONF_OFFSET,
+ offsetof(ngx_http_v2_srv_conf_t, max_requests),
+ NULL },
+
{ ngx_string("http2_max_field_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
h2scf->pool_size = NGX_CONF_UNSET_SIZE;
h2scf->concurrent_streams = NGX_CONF_UNSET_UINT;
+ h2scf->max_requests = NGX_CONF_UNSET_UINT;
h2scf->max_field_size = NGX_CONF_UNSET_SIZE;
h2scf->max_header_size = NGX_CONF_UNSET_SIZE;
ngx_conf_merge_uint_value(conf->concurrent_streams,
prev->concurrent_streams, 128);
+ ngx_conf_merge_uint_value(conf->max_requests, prev->max_requests, 1000);
ngx_conf_merge_size_value(conf->max_field_size, prev->max_field_size,
4096);