changeset 7872:021416fca094

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.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 17 Jun 2021 11:43:55 +0300
parents 5f765427c17a
children 0302a4f0b6c4
files src/http/modules/ngx_http_grpc_module.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_grpc_module.c	Tue Jun 01 17:37:51 2021 +0300
+++ b/src/http/modules/ngx_http_grpc_module.c	Thu Jun 17 11:43:55 2021 +0300
@@ -121,6 +121,7 @@
     unsigned                   done:1;
     unsigned                   status:1;
     unsigned                   rst:1;
+    unsigned                   goaway:1;
 
     ngx_http_request_t        *request;
 
@@ -1210,6 +1211,7 @@
     ctx->done = 0;
     ctx->status = 0;
     ctx->rst = 0;
+    ctx->goaway = 0;
     ctx->connection = NULL;
 
     return NGX_OK;
@@ -1565,6 +1567,7 @@
             && 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 @@
                 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
             }
 
+            ctx->goaway = 1;
+
             continue;
         }
 
@@ -1907,6 +1912,7 @@
                         && ctx->out == NULL
                         && ctx->output_closed
                         && !ctx->output_blocked
+                        && !ctx->goaway
                         && b->last == b->pos)
                     {
                         u->keepalive = 1;
@@ -2035,6 +2041,7 @@
                     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 @@
                 return NGX_ERROR;
             }
 
+            ctx->goaway = 1;
+
             continue;
         }