diff src/http/v3/ngx_http_v3_streams.c @ 8769:9ec3e71f8a61 quic

HTTP/3: reference h3c directly from ngx_http_connection_t. Previously, an ngx_http_v3_connection_t object was created for HTTP/3 and then assinged to c->data instead of the generic ngx_http_connection_t object. Now a direct reference is added to ngx_http_connection_t, which is less confusing and does not require a flag for http3.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 05 May 2021 14:53:36 +0300
parents 40d710a66aef
children 67f0eb150047
line wrap: on
line diff
--- a/src/http/v3/ngx_http_v3_streams.c
+++ b/src/http/v3/ngx_http_v3_streams.c
@@ -46,13 +46,13 @@ ngx_http_v3_init_session(ngx_connection_
 {
     ngx_connection_t          *pc;
     ngx_pool_cleanup_t        *cln;
-    ngx_http_connection_t     *phc;
+    ngx_http_connection_t     *hc;
     ngx_http_v3_connection_t  *h3c;
 
     pc = c->quic->parent;
-    phc = pc->data;
+    hc = pc->data;
 
-    if (phc->http3) {
+    if (hc->v3_session) {
         return NGX_OK;
     }
 
@@ -63,8 +63,6 @@ ngx_http_v3_init_session(ngx_connection_
         return NGX_ERROR;
     }
 
-    h3c->hc = *phc;
-    h3c->hc.http3 = 1;
     h3c->max_push_id = (uint64_t) -1;
 
     ngx_queue_init(&h3c->blocked);
@@ -83,7 +81,7 @@ ngx_http_v3_init_session(ngx_connection_
     cln->handler = ngx_http_v3_cleanup_session;
     cln->data = h3c;
 
-    pc->data = h3c;
+    hc->v3_session = h3c;
 
     return ngx_http_v3_send_settings(c);
 }
@@ -519,13 +517,10 @@ failed:
 static ngx_int_t
 ngx_http_v3_send_settings(ngx_connection_t *c)
 {
-    u_char                    *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6];
-    size_t                     n;
-    ngx_connection_t          *cc;
-    ngx_http_v3_srv_conf_t    *h3scf;
-    ngx_http_v3_connection_t  *h3c;
-
-    h3c = ngx_http_v3_get_session(c);
+    u_char                  *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6];
+    size_t                   n;
+    ngx_connection_t        *cc;
+    ngx_http_v3_srv_conf_t  *h3scf;
 
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings");
 
@@ -534,7 +529,7 @@ ngx_http_v3_send_settings(ngx_connection
         return NGX_DECLINED;
     }
 
-    h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module);
+    h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module);
 
     n = ngx_http_v3_encode_varlen_int(NULL,
                                       NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY);