Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
8768:40d710a66aef | 8769:9ec3e71f8a61 |
---|---|
44 ngx_int_t | 44 ngx_int_t |
45 ngx_http_v3_init_session(ngx_connection_t *c) | 45 ngx_http_v3_init_session(ngx_connection_t *c) |
46 { | 46 { |
47 ngx_connection_t *pc; | 47 ngx_connection_t *pc; |
48 ngx_pool_cleanup_t *cln; | 48 ngx_pool_cleanup_t *cln; |
49 ngx_http_connection_t *phc; | 49 ngx_http_connection_t *hc; |
50 ngx_http_v3_connection_t *h3c; | 50 ngx_http_v3_connection_t *h3c; |
51 | 51 |
52 pc = c->quic->parent; | 52 pc = c->quic->parent; |
53 phc = pc->data; | 53 hc = pc->data; |
54 | 54 |
55 if (phc->http3) { | 55 if (hc->v3_session) { |
56 return NGX_OK; | 56 return NGX_OK; |
57 } | 57 } |
58 | 58 |
59 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); | 59 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); |
60 | 60 |
61 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_connection_t)); | 61 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_connection_t)); |
62 if (h3c == NULL) { | 62 if (h3c == NULL) { |
63 return NGX_ERROR; | 63 return NGX_ERROR; |
64 } | 64 } |
65 | 65 |
66 h3c->hc = *phc; | |
67 h3c->hc.http3 = 1; | |
68 h3c->max_push_id = (uint64_t) -1; | 66 h3c->max_push_id = (uint64_t) -1; |
69 | 67 |
70 ngx_queue_init(&h3c->blocked); | 68 ngx_queue_init(&h3c->blocked); |
71 ngx_queue_init(&h3c->pushing); | 69 ngx_queue_init(&h3c->pushing); |
72 | 70 |
81 } | 79 } |
82 | 80 |
83 cln->handler = ngx_http_v3_cleanup_session; | 81 cln->handler = ngx_http_v3_cleanup_session; |
84 cln->data = h3c; | 82 cln->data = h3c; |
85 | 83 |
86 pc->data = h3c; | 84 hc->v3_session = h3c; |
87 | 85 |
88 return ngx_http_v3_send_settings(c); | 86 return ngx_http_v3_send_settings(c); |
89 } | 87 } |
90 | 88 |
91 | 89 |
517 | 515 |
518 | 516 |
519 static ngx_int_t | 517 static ngx_int_t |
520 ngx_http_v3_send_settings(ngx_connection_t *c) | 518 ngx_http_v3_send_settings(ngx_connection_t *c) |
521 { | 519 { |
522 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6]; | 520 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6]; |
523 size_t n; | 521 size_t n; |
524 ngx_connection_t *cc; | 522 ngx_connection_t *cc; |
525 ngx_http_v3_srv_conf_t *h3scf; | 523 ngx_http_v3_srv_conf_t *h3scf; |
526 ngx_http_v3_connection_t *h3c; | |
527 | |
528 h3c = ngx_http_v3_get_session(c); | |
529 | 524 |
530 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings"); | 525 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings"); |
531 | 526 |
532 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); | 527 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); |
533 if (cc == NULL) { | 528 if (cc == NULL) { |
534 return NGX_DECLINED; | 529 return NGX_DECLINED; |
535 } | 530 } |
536 | 531 |
537 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module); | 532 h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module); |
538 | 533 |
539 n = ngx_http_v3_encode_varlen_int(NULL, | 534 n = ngx_http_v3_encode_varlen_int(NULL, |
540 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY); | 535 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY); |
541 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_table_capacity); | 536 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_table_capacity); |
542 n += ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_PARAM_BLOCKED_STREAMS); | 537 n += ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_PARAM_BLOCKED_STREAMS); |