Mercurial > hg > nginx
comparison src/http/modules/ngx_http_grpc_module.c @ 7417:dc69f7aa6ca6 stable-1.14
gRPC: disabled keepalive when sending control frames was blocked.
If sending request body was not completed (u->request_body_sent is not set),
the upstream keepalive module won't save such a connection. However, it
is theoretically possible (though highly unlikely) that sending of some
control frames can be blocked after the request body was sent. The
ctx->output_blocked flag introduced to disable keepalive in such cases.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 03 Sep 2018 19:34:02 +0300 |
parents | c948804cd628 |
children |
comparison
equal
deleted
inserted
replaced
7416:c948804cd628 | 7417:dc69f7aa6ca6 |
---|---|
110 unsigned literal:1; | 110 unsigned literal:1; |
111 unsigned field_huffman:1; | 111 unsigned field_huffman:1; |
112 | 112 |
113 unsigned header_sent:1; | 113 unsigned header_sent:1; |
114 unsigned output_closed:1; | 114 unsigned output_closed:1; |
115 unsigned output_blocked:1; | |
115 unsigned parsing_headers:1; | 116 unsigned parsing_headers:1; |
116 unsigned end_stream:1; | 117 unsigned end_stream:1; |
117 unsigned done:1; | 118 unsigned done:1; |
118 unsigned status:1; | 119 unsigned status:1; |
119 | 120 |
1074 } | 1075 } |
1075 | 1076 |
1076 ctx->state = 0; | 1077 ctx->state = 0; |
1077 ctx->header_sent = 0; | 1078 ctx->header_sent = 0; |
1078 ctx->output_closed = 0; | 1079 ctx->output_closed = 0; |
1080 ctx->output_blocked = 0; | |
1079 ctx->parsing_headers = 0; | 1081 ctx->parsing_headers = 0; |
1080 ctx->end_stream = 0; | 1082 ctx->end_stream = 0; |
1081 ctx->done = 0; | 1083 ctx->done = 0; |
1082 ctx->status = 0; | 1084 ctx->status = 0; |
1083 ctx->connection = NULL; | 1085 ctx->connection = NULL; |
1411 | 1413 |
1412 if (rc == NGX_OK && ctx->in) { | 1414 if (rc == NGX_OK && ctx->in) { |
1413 rc = NGX_AGAIN; | 1415 rc = NGX_AGAIN; |
1414 } | 1416 } |
1415 | 1417 |
1418 if (rc == NGX_AGAIN) { | |
1419 ctx->output_blocked = 1; | |
1420 | |
1421 } else { | |
1422 ctx->output_blocked = 0; | |
1423 } | |
1424 | |
1416 if (ctx->done) { | 1425 if (ctx->done) { |
1417 | 1426 |
1418 /* | 1427 /* |
1419 * We have already got the response and were sending some additional | 1428 * We have already got the response and were sending some additional |
1420 * control frames. Even if there is still something unsent, stop | 1429 * control frames. Even if there is still something unsent, stop |
1425 u->length = 0; | 1434 u->length = 0; |
1426 | 1435 |
1427 if (ctx->in == NULL | 1436 if (ctx->in == NULL |
1428 && ctx->out == NULL | 1437 && ctx->out == NULL |
1429 && ctx->output_closed | 1438 && ctx->output_closed |
1439 && !ctx->output_blocked | |
1430 && ctx->state == ngx_http_grpc_st_start) | 1440 && ctx->state == ngx_http_grpc_st_start) |
1431 { | 1441 { |
1432 u->keepalive = 1; | 1442 u->keepalive = 1; |
1433 } | 1443 } |
1434 | 1444 |
1775 u->headers_in.content_length_n = 0; | 1785 u->headers_in.content_length_n = 0; |
1776 | 1786 |
1777 if (ctx->in == NULL | 1787 if (ctx->in == NULL |
1778 && ctx->out == NULL | 1788 && ctx->out == NULL |
1779 && ctx->output_closed | 1789 && ctx->output_closed |
1790 && !ctx->output_blocked | |
1780 && b->last == b->pos) | 1791 && b->last == b->pos) |
1781 { | 1792 { |
1782 u->keepalive = 1; | 1793 u->keepalive = 1; |
1783 } | 1794 } |
1784 } | 1795 } |
1877 | 1888 |
1878 u->length = 0; | 1889 u->length = 0; |
1879 | 1890 |
1880 if (ctx->in == NULL | 1891 if (ctx->in == NULL |
1881 && ctx->output_closed | 1892 && ctx->output_closed |
1893 && !ctx->output_blocked | |
1882 && ctx->state == ngx_http_grpc_st_start) | 1894 && ctx->state == ngx_http_grpc_st_start) |
1883 { | 1895 { |
1884 u->keepalive = 1; | 1896 u->keepalive = 1; |
1885 } | 1897 } |
1886 | 1898 |