Update Nginx auf 1.13.1
This commit is contained in:
@@ -529,29 +529,8 @@ ngx_http_v2_send_output_queue(ngx_http_v2_connection_t *h2c)
|
||||
tcp_nodelay = 1;
|
||||
}
|
||||
|
||||
if (tcp_nodelay
|
||||
&& clcf->tcp_nodelay
|
||||
&& c->tcp_nodelay == NGX_TCP_NODELAY_UNSET)
|
||||
{
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
|
||||
|
||||
if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *) &tcp_nodelay, sizeof(int))
|
||||
== -1)
|
||||
{
|
||||
#if (NGX_SOLARIS)
|
||||
/* Solaris returns EINVAL if a socket has been shut down */
|
||||
c->log_error = NGX_ERROR_IGNORE_EINVAL;
|
||||
#endif
|
||||
|
||||
ngx_connection_error(c, ngx_socket_errno,
|
||||
"setsockopt(TCP_NODELAY) failed");
|
||||
|
||||
c->log_error = NGX_ERROR_INFO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
c->tcp_nodelay = NGX_TCP_NODELAY_SET;
|
||||
if (tcp_nodelay && clcf->tcp_nodelay && ngx_tcp_nodelay(c) != NGX_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
for ( /* void */ ; out; out = fn) {
|
||||
@@ -783,9 +762,12 @@ ngx_http_v2_state_head(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end)
|
||||
static u_char *
|
||||
ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end)
|
||||
{
|
||||
size_t size;
|
||||
ngx_http_v2_node_t *node;
|
||||
ngx_http_v2_stream_t *stream;
|
||||
|
||||
size = h2c->state.length;
|
||||
|
||||
if (h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG) {
|
||||
|
||||
if (h2c->state.length == 0) {
|
||||
@@ -802,33 +784,33 @@ ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end)
|
||||
}
|
||||
|
||||
h2c->state.padding = *pos++;
|
||||
h2c->state.length--;
|
||||
|
||||
if (h2c->state.padding > h2c->state.length) {
|
||||
if (h2c->state.padding >= size) {
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client sent padded DATA frame "
|
||||
"with incorrect length: %uz, padding: %uz",
|
||||
h2c->state.length, h2c->state.padding);
|
||||
size, h2c->state.padding);
|
||||
|
||||
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR);
|
||||
return ngx_http_v2_connection_error(h2c,
|
||||
NGX_HTTP_V2_PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
h2c->state.length -= h2c->state.padding;
|
||||
h2c->state.length -= 1 + h2c->state.padding;
|
||||
}
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
|
||||
"http2 DATA frame");
|
||||
|
||||
if (h2c->state.length > h2c->recv_window) {
|
||||
if (size > h2c->recv_window) {
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client violated connection flow control: "
|
||||
"received DATA frame length %uz, available window %uz",
|
||||
h2c->state.length, h2c->recv_window);
|
||||
size, h2c->recv_window);
|
||||
|
||||
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_FLOW_CTRL_ERROR);
|
||||
}
|
||||
|
||||
h2c->recv_window -= h2c->state.length;
|
||||
h2c->recv_window -= size;
|
||||
|
||||
if (h2c->recv_window < NGX_HTTP_V2_MAX_WINDOW / 4) {
|
||||
|
||||
@@ -854,11 +836,11 @@ ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end)
|
||||
|
||||
stream = node->stream;
|
||||
|
||||
if (h2c->state.length > stream->recv_window) {
|
||||
if (size > stream->recv_window) {
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client violated flow control for stream %ui: "
|
||||
"received DATA frame length %uz, available window %uz",
|
||||
node->id, h2c->state.length, stream->recv_window);
|
||||
node->id, size, stream->recv_window);
|
||||
|
||||
if (ngx_http_v2_terminate_stream(h2c, stream,
|
||||
NGX_HTTP_V2_FLOW_CTRL_ERROR)
|
||||
@@ -871,7 +853,7 @@ ngx_http_v2_state_data(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end)
|
||||
return ngx_http_v2_state_skip_padded(h2c, pos, end);
|
||||
}
|
||||
|
||||
stream->recv_window -= h2c->state.length;
|
||||
stream->recv_window -= size;
|
||||
|
||||
if (stream->no_flow_control
|
||||
&& stream->recv_window < NGX_HTTP_V2_MAX_WINDOW / 4)
|
||||
@@ -938,7 +920,7 @@ ngx_http_v2_state_read_data(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
|
||||
if (size >= h2c->state.length) {
|
||||
size = h2c->state.length;
|
||||
stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG;
|
||||
stream->in_closed = h2c->state.flags & NGX_HTTP_V2_END_STREAM_FLAG;
|
||||
}
|
||||
|
||||
r = stream->request;
|
||||
@@ -1053,7 +1035,8 @@ ngx_http_v2_state_headers(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
"with incorrect length: %uz, padding: %uz",
|
||||
h2c->state.length, h2c->state.padding);
|
||||
|
||||
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR);
|
||||
return ngx_http_v2_connection_error(h2c,
|
||||
NGX_HTTP_V2_PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
h2c->state.length -= h2c->state.padding;
|
||||
@@ -1901,7 +1884,7 @@ ngx_http_v2_state_rst_stream(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
|
||||
if (node == NULL || node->stream == NULL) {
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
|
||||
"unknown http2 stream");
|
||||
"unknown http2 stream");
|
||||
|
||||
return ngx_http_v2_state_complete(h2c, pos, end);
|
||||
}
|
||||
@@ -2015,6 +1998,7 @@ ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
break;
|
||||
|
||||
case NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING:
|
||||
|
||||
if (value > NGX_HTTP_V2_MAX_FRAME_SIZE
|
||||
|| value < NGX_HTTP_V2_DEFAULT_FRAME_SIZE)
|
||||
{
|
||||
@@ -2161,6 +2145,44 @@ ngx_http_v2_state_window_update(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
"http2 WINDOW_UPDATE frame sid:%ui window:%uz",
|
||||
h2c->state.sid, window);
|
||||
|
||||
if (window == 0) {
|
||||
if (h2c->state.sid == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client sent WINDOW_UPDATE frame "
|
||||
"with incorrect window increment 0");
|
||||
|
||||
return ngx_http_v2_connection_error(h2c,
|
||||
NGX_HTTP_V2_PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client sent WINDOW_UPDATE frame for stream %ui "
|
||||
"with incorrect window increment 0", h2c->state.sid);
|
||||
|
||||
node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
|
||||
|
||||
if (node && node->stream) {
|
||||
if (ngx_http_v2_terminate_stream(h2c, node->stream,
|
||||
NGX_HTTP_V2_PROTOCOL_ERROR)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
return ngx_http_v2_connection_error(h2c,
|
||||
NGX_HTTP_V2_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid,
|
||||
NGX_HTTP_V2_PROTOCOL_ERROR)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
return ngx_http_v2_connection_error(h2c,
|
||||
NGX_HTTP_V2_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return ngx_http_v2_state_complete(h2c, pos, end);
|
||||
}
|
||||
|
||||
if (h2c->state.sid) {
|
||||
node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
|
||||
|
||||
@@ -3072,7 +3094,7 @@ ngx_http_v2_pseudo_header(ngx_http_request_t *r, ngx_http_v2_header_t *header)
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
"client sent unknown pseudo header \"%V\"",
|
||||
"client sent unknown pseudo-header \":%V\"",
|
||||
&header->name);
|
||||
|
||||
return NGX_DECLINED;
|
||||
@@ -3219,14 +3241,14 @@ ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_http_v2_header_t *header)
|
||||
{
|
||||
if (r->schema_start) {
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
"client sent duplicate :schema header");
|
||||
"client sent duplicate :scheme header");
|
||||
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
if (header->value.len == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
"client sent empty :schema header");
|
||||
"client sent empty :scheme header");
|
||||
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
@@ -3479,8 +3501,7 @@ ngx_http_v2_run_request(ngx_http_request_t *r)
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_v2_read_request_body(ngx_http_request_t *r,
|
||||
ngx_http_client_body_handler_pt post_handler)
|
||||
ngx_http_v2_read_request_body(ngx_http_request_t *r)
|
||||
{
|
||||
off_t len;
|
||||
size_t size;
|
||||
@@ -3493,33 +3514,14 @@ ngx_http_v2_read_request_body(ngx_http_request_t *r,
|
||||
ngx_http_v2_connection_t *h2c;
|
||||
|
||||
stream = r->stream;
|
||||
rb = r->request_body;
|
||||
|
||||
if (stream->skip_data) {
|
||||
r->request_body_no_buffering = 0;
|
||||
post_handler(r);
|
||||
rb->post_handler(r);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
|
||||
if (rb == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* set by ngx_pcalloc():
|
||||
*
|
||||
* rb->bufs = NULL;
|
||||
* rb->buf = NULL;
|
||||
* rb->received = 0;
|
||||
* rb->free = NULL;
|
||||
* rb->busy = NULL;
|
||||
*/
|
||||
|
||||
rb->rest = 1;
|
||||
rb->post_handler = post_handler;
|
||||
|
||||
r->request_body = rb;
|
||||
|
||||
h2scf = ngx_http_get_module_srv_conf(r, ngx_http_v2_module);
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
@@ -3569,6 +3571,8 @@ ngx_http_v2_read_request_body(ngx_http_request_t *r,
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
rb->rest = 1;
|
||||
|
||||
buf = stream->preread;
|
||||
|
||||
if (stream->in_closed) {
|
||||
@@ -4130,6 +4134,14 @@ ngx_http_v2_handle_connection_handler(ngx_event_t *rev)
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
|
||||
"http2 handle connection handler");
|
||||
|
||||
c = rev->data;
|
||||
h2c = c->data;
|
||||
|
||||
if (c->error) {
|
||||
ngx_http_v2_finalize_connection(h2c, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
rev->handler = ngx_http_v2_read_handler;
|
||||
|
||||
if (rev->ready) {
|
||||
@@ -4137,9 +4149,6 @@ ngx_http_v2_handle_connection_handler(ngx_event_t *rev)
|
||||
return;
|
||||
}
|
||||
|
||||
c = rev->data;
|
||||
h2c = c->data;
|
||||
|
||||
if (h2c->last_out && ngx_http_v2_send_output_queue(h2c) == NGX_ERROR) {
|
||||
ngx_http_v2_finalize_connection(h2c, 0);
|
||||
return;
|
||||
@@ -4262,7 +4271,10 @@ ngx_http_v2_finalize_connection(ngx_http_v2_connection_t *h2c,
|
||||
|
||||
if (stream->queued) {
|
||||
stream->queued = 0;
|
||||
|
||||
ev = fc->write;
|
||||
ev->active = 0;
|
||||
ev->ready = 1;
|
||||
|
||||
} else {
|
||||
ev = fc->read;
|
||||
|
||||
Reference in New Issue
Block a user