comparison src/http/v3/ngx_http_v3_request.c @ 9055:1192923be0aa quic

QUIC: idle mode for main connection. Now main QUIC connection for HTTP/3 always has c->idle flag set. This allows the connection to receive worker shutdown notification. It is passed to application level via a new conf->shutdown() callback. The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down the QUIC connection.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 19 Oct 2022 17:45:18 +0400
parents 6546c2ae1c7b
children 7b83da3bdf9f
comparison
equal deleted inserted replaced
9054:6546c2ae1c7b 9055:1192923be0aa
98 ngx_http_v3_init_request_stream(c); 98 ngx_http_v3_init_request_stream(c);
99 } 99 }
100 } 100 }
101 101
102 102
103 void
104 ngx_http_v3_shutdown(ngx_connection_t *c)
105 {
106 ngx_http_v3_session_t *h3c;
107
108 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 shutdown");
109
110 h3c = ngx_http_v3_get_session(c);
111
112 if (h3c == NULL) {
113 ngx_quic_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR,
114 "connection shutdown");
115 return;
116 }
117
118 if (!h3c->goaway) {
119 h3c->goaway = 1;
120
121 #if (NGX_HTTP_V3_HQ)
122 if (!h3c->hq)
123 #endif
124 {
125 (void) ngx_http_v3_send_goaway(c, h3c->next_request_id);
126 }
127
128 ngx_http_v3_shutdown_connection(c, NGX_HTTP_V3_ERR_NO_ERROR,
129 "connection shutdown");
130 }
131 }
132
133
103 static void 134 static void
104 ngx_http_v3_init_request_stream(ngx_connection_t *c) 135 ngx_http_v3_init_request_stream(ngx_connection_t *c)
105 { 136 {
106 uint64_t n; 137 uint64_t n;
107 ngx_event_t *rev; 138 ngx_event_t *rev;
138 return; 169 return;
139 } 170 }
140 171
141 pc = c->quic->parent; 172 pc = c->quic->parent;
142 173
174 h3c->next_request_id = c->quic->id + 0x04;
175
143 if (n + 1 == clcf->keepalive_requests 176 if (n + 1 == clcf->keepalive_requests
144 || ngx_current_msec - pc->start_time > clcf->keepalive_time) 177 || ngx_current_msec - pc->start_time > clcf->keepalive_time)
145 { 178 {
146 h3c->goaway = 1; 179 h3c->goaway = 1;
147 180
148 #if (NGX_HTTP_V3_HQ) 181 #if (NGX_HTTP_V3_HQ)
149 if (!h3c->hq) 182 if (!h3c->hq)
150 #endif 183 #endif
151 { 184 {
152 if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) { 185 if (ngx_http_v3_send_goaway(c, h3c->next_request_id) != NGX_OK) {
153 ngx_http_close_connection(c); 186 ngx_http_close_connection(c);
154 return; 187 return;
155 } 188 }
156 } 189 }
157 190