comparison src/http/v3/ngx_http_v3_request.c @ 8723:265062a99043 quic

HTTP/3: send GOAWAY when last request is accepted. The last request in connection is determined according to the keepalive_requests directive. Requests beyond keepalive_requests are rejected.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 15 Mar 2021 19:26:04 +0300
parents ffcaf0aad9f2
children fc64ab301bad
comparison
equal deleted inserted replaced
8722:7a07724256c2 8723:265062a99043
50 50
51 void 51 void
52 ngx_http_v3_init(ngx_connection_t *c) 52 ngx_http_v3_init(ngx_connection_t *c)
53 { 53 {
54 size_t size; 54 size_t size;
55 uint64_t n;
55 ngx_buf_t *b; 56 ngx_buf_t *b;
56 ngx_event_t *rev; 57 ngx_event_t *rev;
57 ngx_http_request_t *r; 58 ngx_http_request_t *r;
58 ngx_http_connection_t *hc; 59 ngx_http_connection_t *hc;
60 ngx_http_core_loc_conf_t *clcf;
59 ngx_http_core_srv_conf_t *cscf; 61 ngx_http_core_srv_conf_t *cscf;
60 62
61 if (ngx_http_v3_init_session(c) != NGX_OK) { 63 if (ngx_http_v3_init_session(c) != NGX_OK) {
62 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR, 64 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
63 "internal error"); 65 "internal error");
71 } 73 }
72 74
73 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init request stream"); 75 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init request stream");
74 76
75 hc = c->data; 77 hc = c->data;
78
79 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
80
81 n = c->quic->id >> 2;
82
83 if (n >= clcf->keepalive_requests) {
84 ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED);
85 ngx_http_close_connection(c);
86 return;
87 }
88
89 if (n + 1 == clcf->keepalive_requests) {
90 if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) {
91 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
92 "goaway error");
93 ngx_http_close_connection(c);
94 return;
95 }
96 }
76 97
77 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module); 98 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
78 99
79 size = cscf->client_header_buffer_size; 100 size = cscf->client_header_buffer_size;
80 101