Mercurial > hg > nginx-quic
comparison src/http/v3/ngx_http_v3.c @ 8990:b0c2234aaa9f quic
QUIC: application init() callback.
It's called after handshake completion or prior to the first early data stream
creation. The callback should initialize application-level data before
creating streams.
HTTP/3 callback implementation sets keepalive timer and sends SETTINGS.
Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 30 Nov 2022 12:51:15 +0400 |
parents | be39ffdf9208 |
children | c851a2ed5ce8 |
comparison
equal
deleted
inserted
replaced
8989:7b83da3bdf9f | 8990:b0c2234aaa9f |
---|---|
15 | 15 |
16 | 16 |
17 ngx_int_t | 17 ngx_int_t |
18 ngx_http_v3_init_session(ngx_connection_t *c) | 18 ngx_http_v3_init_session(ngx_connection_t *c) |
19 { | 19 { |
20 ngx_connection_t *pc; | |
21 ngx_pool_cleanup_t *cln; | 20 ngx_pool_cleanup_t *cln; |
22 ngx_http_connection_t *hc; | 21 ngx_http_connection_t *hc; |
23 ngx_http_v3_session_t *h3c; | 22 ngx_http_v3_session_t *h3c; |
24 #if (NGX_HTTP_V3_HQ) | 23 #if (NGX_HTTP_V3_HQ) |
25 ngx_http_v3_srv_conf_t *h3scf; | 24 ngx_http_v3_srv_conf_t *h3scf; |
26 #endif | 25 #endif |
27 | 26 |
28 pc = c->quic->parent; | 27 hc = c->data; |
29 hc = pc->data; | |
30 | |
31 if (hc->v3_session) { | |
32 return NGX_OK; | |
33 } | |
34 | 28 |
35 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); | 29 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); |
36 | 30 |
37 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t)); | 31 h3c = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_session_t)); |
38 if (h3c == NULL) { | 32 if (h3c == NULL) { |
39 goto failed; | 33 goto failed; |
40 } | 34 } |
41 | 35 |
42 h3c->max_push_id = (uint64_t) -1; | 36 h3c->max_push_id = (uint64_t) -1; |
50 #endif | 44 #endif |
51 | 45 |
52 ngx_queue_init(&h3c->blocked); | 46 ngx_queue_init(&h3c->blocked); |
53 ngx_queue_init(&h3c->pushing); | 47 ngx_queue_init(&h3c->pushing); |
54 | 48 |
55 h3c->keepalive.log = pc->log; | 49 h3c->keepalive.log = c->log; |
56 h3c->keepalive.data = pc; | 50 h3c->keepalive.data = c; |
57 h3c->keepalive.handler = ngx_http_v3_keepalive_handler; | 51 h3c->keepalive.handler = ngx_http_v3_keepalive_handler; |
58 | 52 |
59 h3c->table.send_insert_count.log = pc->log; | 53 h3c->table.send_insert_count.log = c->log; |
60 h3c->table.send_insert_count.data = pc; | 54 h3c->table.send_insert_count.data = c; |
61 h3c->table.send_insert_count.handler = ngx_http_v3_inc_insert_count_handler; | 55 h3c->table.send_insert_count.handler = ngx_http_v3_inc_insert_count_handler; |
62 | 56 |
63 cln = ngx_pool_cleanup_add(pc->pool, 0); | 57 cln = ngx_pool_cleanup_add(c->pool, 0); |
64 if (cln == NULL) { | 58 if (cln == NULL) { |
65 goto failed; | 59 goto failed; |
66 } | 60 } |
67 | 61 |
68 cln->handler = ngx_http_v3_cleanup_session; | 62 cln->handler = ngx_http_v3_cleanup_session; |
69 cln->data = h3c; | 63 cln->data = h3c; |
70 | 64 |
71 hc->v3_session = h3c; | 65 hc->v3_session = h3c; |
72 | 66 |
73 #if (NGX_HTTP_V3_HQ) | 67 return NGX_OK; |
74 if (h3c->hq) { | |
75 return NGX_OK; | |
76 } | |
77 #endif | |
78 | |
79 return ngx_http_v3_send_settings(c); | |
80 | 68 |
81 failed: | 69 failed: |
82 | 70 |
83 ngx_log_error(NGX_LOG_ERR, c->log, 0, "failed to create http3 session"); | 71 ngx_log_error(NGX_LOG_ERR, c->log, 0, "failed to create http3 session"); |
84 | 72 |