forked from Hakase/nginx-build
Latest update - 7350
This commit is contained in:
@@ -109,8 +109,10 @@ typedef struct {
|
||||
|
||||
unsigned header_sent:1;
|
||||
unsigned output_closed:1;
|
||||
unsigned output_blocked:1;
|
||||
unsigned parsing_headers:1;
|
||||
unsigned end_stream:1;
|
||||
unsigned done:1;
|
||||
unsigned status:1;
|
||||
|
||||
ngx_http_request_t *request;
|
||||
@@ -1072,8 +1074,10 @@ ngx_http_grpc_reinit_request(ngx_http_request_t *r)
|
||||
ctx->state = 0;
|
||||
ctx->header_sent = 0;
|
||||
ctx->output_closed = 0;
|
||||
ctx->output_blocked = 0;
|
||||
ctx->parsing_headers = 0;
|
||||
ctx->end_stream = 0;
|
||||
ctx->done = 0;
|
||||
ctx->status = 0;
|
||||
ctx->connection = NULL;
|
||||
|
||||
@@ -1093,6 +1097,7 @@ ngx_http_grpc_body_output_filter(void *data, ngx_chain_t *in)
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t next, last;
|
||||
ngx_chain_t *cl, *out, **ll;
|
||||
ngx_http_upstream_t *u;
|
||||
ngx_http_grpc_ctx_t *ctx;
|
||||
ngx_http_grpc_frame_t *f;
|
||||
|
||||
@@ -1407,6 +1412,36 @@ ngx_http_grpc_body_output_filter(void *data, ngx_chain_t *in)
|
||||
rc = NGX_AGAIN;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
ctx->output_blocked = 1;
|
||||
|
||||
} else {
|
||||
ctx->output_blocked = 0;
|
||||
}
|
||||
|
||||
if (ctx->done) {
|
||||
|
||||
/*
|
||||
* We have already got the response and were sending some additional
|
||||
* control frames. Even if there is still something unsent, stop
|
||||
* here anyway.
|
||||
*/
|
||||
|
||||
u = r->upstream;
|
||||
u->length = 0;
|
||||
|
||||
if (ctx->in == NULL
|
||||
&& ctx->out == NULL
|
||||
&& ctx->output_closed
|
||||
&& !ctx->output_blocked
|
||||
&& ctx->state == ngx_http_grpc_st_start)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
}
|
||||
|
||||
ngx_post_event(u->peer.connection->read, &ngx_posted_events);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1749,6 +1784,7 @@ ngx_http_grpc_process_header(ngx_http_request_t *r)
|
||||
if (ctx->in == NULL
|
||||
&& ctx->out == NULL
|
||||
&& ctx->output_closed
|
||||
&& !ctx->output_blocked
|
||||
&& b->last == b->pos)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
@@ -1832,6 +1868,34 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
rc = ngx_http_grpc_parse_frame(r, ctx, b);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
|
||||
if (ctx->done) {
|
||||
|
||||
/*
|
||||
* We have finished parsing the response and the
|
||||
* remaining control frames. If there are unsent
|
||||
* control frames, post a write event to send them.
|
||||
*/
|
||||
|
||||
if (ctx->out) {
|
||||
ngx_post_event(u->peer.connection->write,
|
||||
&ngx_posted_events);
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
u->length = 0;
|
||||
|
||||
if (ctx->in == NULL
|
||||
&& ctx->output_closed
|
||||
&& !ctx->output_blocked
|
||||
&& ctx->state == ngx_http_grpc_st_start)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
@@ -1898,6 +1962,13 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (ctx->stream_id && ctx->done) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"upstream sent frame for closed stream %ui",
|
||||
ctx->stream_id);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ctx->padding = 0;
|
||||
}
|
||||
|
||||
@@ -1914,17 +1985,7 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
ctx->state = ngx_http_grpc_st_start;
|
||||
|
||||
if (ctx->flags & NGX_HTTP_V2_END_STREAM_FLAG) {
|
||||
u->length = 0;
|
||||
|
||||
if (ctx->in == NULL
|
||||
&& ctx->out == NULL
|
||||
&& ctx->output_closed
|
||||
&& b->last == b->pos)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
ctx->done = 1;
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -2094,17 +2155,8 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
"grpc trailer done");
|
||||
|
||||
if (ctx->end_stream) {
|
||||
u->length = 0;
|
||||
|
||||
if (ctx->in == NULL
|
||||
&& ctx->out == NULL
|
||||
&& ctx->output_closed
|
||||
&& b->last == b->pos)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
ctx->done = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
@@ -2121,6 +2173,10 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* rc == NGX_AGAIN */
|
||||
|
||||
if (ctx->rest == 0) {
|
||||
@@ -2237,17 +2293,7 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
|
||||
ctx->state = ngx_http_grpc_st_start;
|
||||
|
||||
if (ctx->flags & NGX_HTTP_V2_END_STREAM_FLAG) {
|
||||
u->length = 0;
|
||||
|
||||
if (ctx->in == NULL
|
||||
&& ctx->out == NULL
|
||||
&& ctx->output_closed
|
||||
&& b->last == b->pos)
|
||||
{
|
||||
u->keepalive = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
ctx->done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -960,6 +960,12 @@ ngx_http_uwsgi_create_request(ngx_http_request_t *r)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len > 65535) {
|
||||
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
||||
"uwsgi request is too big: %uz", len);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
b = ngx_create_temp_buf(r->pool, len + 4);
|
||||
if (b == NULL) {
|
||||
return NGX_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user