aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_grpc_module.c
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2021-06-17 11:43:55 +0300
committerSergey Kandaurov <pluknet@nginx.com>2021-06-17 11:43:55 +0300
commitdcdf7ec096f0998e689b7f0b0f7541e197eeff6a (patch)
tree7e21c4d1064e805aca41980f741c9dda6e93f1c0 /src/http/modules/ngx_http_grpc_module.c
parent5eadaf69e394c030056e4190d86dae0262f8617c (diff)
downloadnginx-dcdf7ec096f0998e689b7f0b0f7541e197eeff6a.tar.gz
nginx-dcdf7ec096f0998e689b7f0b0f7541e197eeff6a.zip
gRPC: handling GOAWAY with a higher last stream identifier.
Previously, once received from upstream, it couldn't limit opening additional streams in a cached keepalive connection.
Diffstat (limited to 'src/http/modules/ngx_http_grpc_module.c')
-rw-r--r--src/http/modules/ngx_http_grpc_module.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_grpc_module.c b/src/http/modules/ngx_http_grpc_module.c
index 2e20e5ffd..42a540f19 100644
--- a/src/http/modules/ngx_http_grpc_module.c
+++ b/src/http/modules/ngx_http_grpc_module.c
@@ -121,6 +121,7 @@ typedef struct {
unsigned done:1;
unsigned status:1;
unsigned rst:1;
+ unsigned goaway:1;
ngx_http_request_t *request;
@@ -1210,6 +1211,7 @@ ngx_http_grpc_reinit_request(ngx_http_request_t *r)
ctx->done = 0;
ctx->status = 0;
ctx->rst = 0;
+ ctx->goaway = 0;
ctx->connection = NULL;
return NGX_OK;
@@ -1565,6 +1567,7 @@ ngx_http_grpc_body_output_filter(void *data, ngx_chain_t *in)
&& ctx->out == NULL
&& ctx->output_closed
&& !ctx->output_blocked
+ && !ctx->goaway
&& ctx->state == ngx_http_grpc_st_start)
{
u->keepalive = 1;
@@ -1714,6 +1717,8 @@ ngx_http_grpc_process_header(ngx_http_request_t *r)
return NGX_HTTP_UPSTREAM_INVALID_HEADER;
}
+ ctx->goaway = 1;
+
continue;
}
@@ -1907,6 +1912,7 @@ ngx_http_grpc_process_header(ngx_http_request_t *r)
&& ctx->out == NULL
&& ctx->output_closed
&& !ctx->output_blocked
+ && !ctx->goaway
&& b->last == b->pos)
{
u->keepalive = 1;
@@ -2035,6 +2041,7 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
if (ctx->in == NULL
&& ctx->output_closed
&& !ctx->output_blocked
+ && !ctx->goaway
&& ctx->state == ngx_http_grpc_st_start)
{
u->keepalive = 1;
@@ -2204,6 +2211,8 @@ ngx_http_grpc_filter(void *data, ssize_t bytes)
return NGX_ERROR;
}
+ ctx->goaway = 1;
+
continue;
}