Mercurial > hg > nginx-quic
comparison src/http/v3/ngx_http_v3_streams.c @ 8434:f4d3f5d93a82 quic
HTTP/3: moved session initialization to a separate file.
Previously it was in ngx_http_v3_streams.c, but it's unrelated to streams.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 05 May 2021 15:15:48 +0300 |
parents | 345370fdd32d |
children | 1fec68e322d0 |
comparison
equal
deleted
inserted
replaced
8433:b43e50f47b2e | 8434:f4d3f5d93a82 |
---|---|
22 ngx_connection_t *connection; | 22 ngx_connection_t *connection; |
23 ngx_uint_t *npushing; | 23 ngx_uint_t *npushing; |
24 } ngx_http_v3_push_t; | 24 } ngx_http_v3_push_t; |
25 | 25 |
26 | 26 |
27 static void ngx_http_v3_keepalive_handler(ngx_event_t *ev); | |
28 static void ngx_http_v3_cleanup_session(void *data); | |
29 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c); | 27 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c); |
30 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev); | 28 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev); |
31 static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev); | 29 static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev); |
32 static void ngx_http_v3_push_cleanup(void *data); | 30 static void ngx_http_v3_push_cleanup(void *data); |
33 static ngx_connection_t *ngx_http_v3_get_uni_stream(ngx_connection_t *c, | 31 static ngx_connection_t *ngx_http_v3_get_uni_stream(ngx_connection_t *c, |
34 ngx_uint_t type); | 32 ngx_uint_t type); |
35 static ngx_int_t ngx_http_v3_send_settings(ngx_connection_t *c); | |
36 | |
37 | |
38 ngx_int_t | |
39 ngx_http_v3_init_session(ngx_connection_t *c) | |
40 { | |
41 ngx_connection_t *pc; | |
42 ngx_pool_cleanup_t *cln; | |
43 ngx_http_connection_t *hc; | |
44 ngx_http_v3_session_t *h3c; | |
45 | |
46 pc = c->quic->parent; | |
47 hc = pc->data; | |
48 | |
49 if (hc->v3_session) { | |
50 return NGX_OK; | |
51 } | |
52 | |
53 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init session"); | |
54 | |
55 h3c = ngx_pcalloc(pc->pool, sizeof(ngx_http_v3_session_t)); | |
56 if (h3c == NULL) { | |
57 return NGX_ERROR; | |
58 } | |
59 | |
60 h3c->max_push_id = (uint64_t) -1; | |
61 | |
62 ngx_queue_init(&h3c->blocked); | |
63 ngx_queue_init(&h3c->pushing); | |
64 | |
65 h3c->keepalive.log = pc->log; | |
66 h3c->keepalive.data = pc; | |
67 h3c->keepalive.handler = ngx_http_v3_keepalive_handler; | |
68 h3c->keepalive.cancelable = 1; | |
69 | |
70 cln = ngx_pool_cleanup_add(pc->pool, 0); | |
71 if (cln == NULL) { | |
72 return NGX_ERROR; | |
73 } | |
74 | |
75 cln->handler = ngx_http_v3_cleanup_session; | |
76 cln->data = h3c; | |
77 | |
78 hc->v3_session = h3c; | |
79 | |
80 return ngx_http_v3_send_settings(c); | |
81 } | |
82 | |
83 | |
84 static void | |
85 ngx_http_v3_keepalive_handler(ngx_event_t *ev) | |
86 { | |
87 ngx_connection_t *c; | |
88 | |
89 c = ev->data; | |
90 | |
91 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 keepalive handler"); | |
92 | |
93 ngx_quic_finalize_connection(c, NGX_HTTP_V3_ERR_NO_ERROR, | |
94 "keepalive timeout"); | |
95 } | |
96 | |
97 | |
98 static void | |
99 ngx_http_v3_cleanup_session(void *data) | |
100 { | |
101 ngx_http_v3_session_t *h3c = data; | |
102 | |
103 if (h3c->keepalive.timer_set) { | |
104 ngx_del_timer(&h3c->keepalive); | |
105 } | |
106 } | |
107 | 33 |
108 | 34 |
109 void | 35 void |
110 ngx_http_v3_init_uni_stream(ngx_connection_t *c) | 36 ngx_http_v3_init_uni_stream(ngx_connection_t *c) |
111 { | 37 { |
443 | 369 |
444 return NULL; | 370 return NULL; |
445 } | 371 } |
446 | 372 |
447 | 373 |
448 static ngx_int_t | 374 ngx_int_t |
449 ngx_http_v3_send_settings(ngx_connection_t *c) | 375 ngx_http_v3_send_settings(ngx_connection_t *c) |
450 { | 376 { |
451 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6]; | 377 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6]; |
452 size_t n; | 378 size_t n; |
453 ngx_connection_t *cc; | 379 ngx_connection_t *cc; |