Klaus Demo nginx / 456e213
HTTP/2: close connection on frames with self-dependency. Don't waste server resources by sending RST_STREAM frames. Instead, reject HEADERS and PRIORITY frames with self-dependency by closing connection with PROTOCOL_ERROR. Ruslan Ermilov 2 years ago
1 changed file(s) with 9 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
11061106 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
11071107 }
11081108
1109 h2c->last_sid = h2c->state.sid;
1110
1111 h2c->state.pool = ngx_create_pool(1024, h2c->connection->log);
1112 if (h2c->state.pool == NULL) {
1113 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
1114 }
1115
11161109 if (depend == h2c->state.sid) {
11171110 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
11181111 "client sent HEADERS frame for stream %ui "
11191112 "with incorrect dependency", h2c->state.sid);
11201113
1121 status = NGX_HTTP_V2_PROTOCOL_ERROR;
1122 goto rst_stream;
1114 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
1115 }
1116
1117 h2c->last_sid = h2c->state.sid;
1118
1119 h2c->state.pool = ngx_create_pool(1024, h2c->connection->log);
1120 if (h2c->state.pool == NULL) {
1121 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
11231122 }
11241123
11251124 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
18481847 "client sent PRIORITY frame for stream %ui "
18491848 "with incorrect dependency", h2c->state.sid);
18501849
1851 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
1852
1853 if (node && node->stream) {
1854 if (ngx_http_v2_terminate_stream(h2c, node->stream,
1855 NGX_HTTP_V2_PROTOCOL_ERROR)
1856 == NGX_ERROR)
1857 {
1858 return ngx_http_v2_connection_error(h2c,
1859 NGX_HTTP_V2_INTERNAL_ERROR);
1860 }
1861
1862 } else {
1863 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid,
1864 NGX_HTTP_V2_PROTOCOL_ERROR)
1865 == NGX_ERROR)
1866 {
1867 return ngx_http_v2_connection_error(h2c,
1868 NGX_HTTP_V2_INTERNAL_ERROR);
1869 }
1870 }
1871
1872 return ngx_http_v2_state_complete(h2c, pos, end);
1850 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
18731851 }
18741852
18751853 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1);