]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: keepalive_time support.
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 16 Apr 2021 16:42:03 +0000 (19:42 +0300)
committerSergey Kandaurov <pluknet@nginx.com>
Fri, 16 Apr 2021 16:42:03 +0000 (19:42 +0300)
src/http/v3/ngx_http_v3.h
src/http/v3/ngx_http_v3_request.c

index 18b7a76364186676651cceaffc9af65960093844..45d1a3671b627006d2139a4a303c76c40a4c3fb0 100644 (file)
@@ -143,6 +143,8 @@ typedef struct {
     uint64_t                      next_push_id;
     uint64_t                      max_push_id;
 
+    ngx_uint_t                    goaway;  /* unsigned  goaway:1; */
+
     ngx_connection_t             *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
 } ngx_http_v3_connection_t;
 
index 4dc67307820591a53f93bb19bbc8ea81d4584469..c459efef5c7c5a50db7b1f14432a12e78e4d50ed 100644 (file)
@@ -81,15 +81,22 @@ ngx_http_v3_init(ngx_connection_t *c)
 
     clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
 
-    n = c->quic->id >> 2;
+    h3c = c->quic->parent->data;
 
-    if (n >= clcf->keepalive_requests) {
+    if (h3c->goaway) {
         ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED);
         ngx_http_close_connection(c);
         return;
     }
 
-    if (n + 1 == clcf->keepalive_requests) {
+    n = c->quic->id >> 2;
+
+    if (n + 1 == clcf->keepalive_requests
+        || ngx_current_msec - c->quic->parent->start_time
+           > clcf->keepalive_time)
+    {
+        h3c->goaway = 1;
+
         if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) {
             ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
                                             "goaway error");
@@ -110,7 +117,6 @@ ngx_http_v3_init(ngx_connection_t *c)
     cln->handler = ngx_http_v3_cleanup_request;
     cln->data = c;
 
-    h3c = c->quic->parent->data;
     h3c->nrequests++;
 
     if (h3c->keepalive.timer_set) {