comparison src/http/v3/ngx_http_v3_request.c @ 9058: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 7b83da3bdf9f
children b87a0dbc1150
comparison
equal deleted inserted replaced
9057:7b83da3bdf9f 9058:b0c2234aaa9f
55 55
56 56
57 void 57 void
58 ngx_http_v3_init_stream(ngx_connection_t *c) 58 ngx_http_v3_init_stream(ngx_connection_t *c)
59 { 59 {
60 ngx_http_v3_session_t *h3c;
60 ngx_http_connection_t *hc, *phc; 61 ngx_http_connection_t *hc, *phc;
61 ngx_http_v3_srv_conf_t *h3scf; 62 ngx_http_v3_srv_conf_t *h3scf;
62 ngx_http_core_loc_conf_t *clcf; 63 ngx_http_core_loc_conf_t *clcf;
64 ngx_http_core_srv_conf_t *cscf;
63 65
64 hc = c->data; 66 hc = c->data;
65 67
66 hc->ssl = 1; 68 hc->ssl = 1;
67 69
68 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module); 70 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
71 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
69 h3scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module); 72 h3scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module);
70 73
71 if (c->quic == NULL) { 74 if (c->quic == NULL) {
75 if (ngx_http_v3_init_session(c) != NGX_OK) {
76 ngx_http_close_connection(c);
77 return;
78 }
79
80 h3c = hc->v3_session;
81 ngx_add_timer(&h3c->keepalive, cscf->client_header_timeout);
82
72 h3scf->quic.timeout = clcf->keepalive_timeout; 83 h3scf->quic.timeout = clcf->keepalive_timeout;
73 ngx_quic_run(c, &h3scf->quic); 84 ngx_quic_run(c, &h3scf->quic);
74 return; 85 return;
75 } 86 }
76 87
84 hc->conf_ctx = phc->conf_ctx; 95 hc->conf_ctx = phc->conf_ctx;
85 96
86 ngx_set_connection_log(c, clcf->error_log); 97 ngx_set_connection_log(c, clcf->error_log);
87 } 98 }
88 99
89 if (ngx_http_v3_init_session(c) != NGX_OK) {
90 ngx_http_close_connection(c);
91 return;
92 }
93
94 if (c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { 100 if (c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) {
95 ngx_http_v3_init_uni_stream(c); 101 ngx_http_v3_init_uni_stream(c);
96 102
97 } else { 103 } else {
98 ngx_http_v3_init_request_stream(c); 104 ngx_http_v3_init_request_stream(c);
99 } 105 }
106 }
107
108
109 ngx_int_t
110 ngx_http_v3_init(ngx_connection_t *c)
111 {
112 ngx_http_v3_session_t *h3c;
113 ngx_http_core_loc_conf_t *clcf;
114
115 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init");
116
117 h3c = ngx_http_v3_get_session(c);
118 clcf = ngx_http_v3_get_module_loc_conf(c, ngx_http_core_module);
119 ngx_add_timer(&h3c->keepalive, clcf->keepalive_timeout);
120
121 #if (NGX_HTTP_V3_HQ)
122 if (h3c->hq) {
123 return NGX_OK;
124 }
125 #endif
126
127 return ngx_http_v3_send_settings(c);
100 } 128 }
101 129
102 130
103 void 131 void
104 ngx_http_v3_shutdown(ngx_connection_t *c) 132 ngx_http_v3_shutdown(ngx_connection_t *c)