Mercurial > hg > nginx
comparison src/event/ngx_event_quic.c @ 8472:3b15732ac03f quic
QUIC: renaming.
The c->quic->retransmit timer is now called "pto".
The ngx_quic_retransmit() function is renamed to "ngx_quic_detect_lost()".
This is a preparation for the following patches.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 13 Jul 2020 10:07:15 +0300 |
parents | 9ed4c12ec948 |
children | 1b9db5c8c29b |
comparison
equal
deleted
inserted
replaced
8471:9ed4c12ec948 | 8472:3b15732ac03f |
---|---|
92 ngx_quic_frames_stream_t crypto[NGX_QUIC_ENCRYPTION_LAST]; | 92 ngx_quic_frames_stream_t crypto[NGX_QUIC_ENCRYPTION_LAST]; |
93 | 93 |
94 ngx_ssl_t *ssl; | 94 ngx_ssl_t *ssl; |
95 | 95 |
96 ngx_event_t push; | 96 ngx_event_t push; |
97 ngx_event_t retransmit; | 97 ngx_event_t pto; |
98 ngx_event_t close; | 98 ngx_event_t close; |
99 ngx_queue_t free_frames; | 99 ngx_queue_t free_frames; |
100 ngx_msec_t last_cc; | 100 ngx_msec_t last_cc; |
101 | 101 |
102 ngx_msec_t latest_rtt; | 102 ngx_msec_t latest_rtt; |
243 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames); | 243 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames); |
244 static ngx_int_t ngx_quic_send_frames(ngx_connection_t *c, ngx_queue_t *frames); | 244 static ngx_int_t ngx_quic_send_frames(ngx_connection_t *c, ngx_queue_t *frames); |
245 | 245 |
246 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt, | 246 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt, |
247 ngx_quic_send_ctx_t *ctx); | 247 ngx_quic_send_ctx_t *ctx); |
248 static void ngx_quic_retransmit_handler(ngx_event_t *ev); | 248 static void ngx_quic_pto_handler(ngx_event_t *ev); |
249 static ngx_int_t ngx_quic_retransmit(ngx_connection_t *c, | 249 static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c, |
250 ngx_quic_send_ctx_t *ctx, ngx_msec_t *waitp); | 250 ngx_quic_send_ctx_t *ctx, ngx_msec_t *waitp); |
251 static void ngx_quic_push_handler(ngx_event_t *ev); | 251 static void ngx_quic_push_handler(ngx_event_t *ev); |
252 | 252 |
253 static void ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, | 253 static void ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, |
254 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); | 254 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
681 | 681 |
682 /* | 682 /* |
683 * qc->latest_rtt = 0 | 683 * qc->latest_rtt = 0 |
684 */ | 684 */ |
685 | 685 |
686 qc->retransmit.log = c->log; | 686 qc->pto.log = c->log; |
687 qc->retransmit.data = c; | 687 qc->pto.data = c; |
688 qc->retransmit.handler = ngx_quic_retransmit_handler; | 688 qc->pto.handler = ngx_quic_pto_handler; |
689 qc->retransmit.cancelable = 1; | 689 qc->pto.cancelable = 1; |
690 | 690 |
691 qc->push.log = c->log; | 691 qc->push.log = c->log; |
692 qc->push.data = c; | 692 qc->push.data = c; |
693 qc->push.handler = ngx_quic_push_handler; | 693 qc->push.handler = ngx_quic_push_handler; |
694 qc->push.cancelable = 1; | 694 qc->push.cancelable = 1; |
1386 | 1386 |
1387 if (qc->push.timer_set) { | 1387 if (qc->push.timer_set) { |
1388 ngx_del_timer(&qc->push); | 1388 ngx_del_timer(&qc->push); |
1389 } | 1389 } |
1390 | 1390 |
1391 if (qc->retransmit.timer_set) { | 1391 if (qc->pto.timer_set) { |
1392 ngx_del_timer(&qc->retransmit); | 1392 ngx_del_timer(&qc->pto); |
1393 } | 1393 } |
1394 | 1394 |
1395 if (qc->push.posted) { | 1395 if (qc->push.posted) { |
1396 ngx_delete_posted_event(&qc->push); | 1396 ngx_delete_posted_event(&qc->push); |
1397 } | 1397 } |
3258 if (!qc->send_timer_set && !qc->closing) { | 3258 if (!qc->send_timer_set && !qc->closing) { |
3259 qc->send_timer_set = 1; | 3259 qc->send_timer_set = 1; |
3260 ngx_add_timer(c->read, qc->tp.max_idle_timeout); | 3260 ngx_add_timer(c->read, qc->tp.max_idle_timeout); |
3261 } | 3261 } |
3262 | 3262 |
3263 if (!qc->retransmit.timer_set && !qc->closing) { | 3263 if (!qc->pto.timer_set && !qc->closing) { |
3264 ngx_add_timer(&qc->retransmit, | 3264 ngx_add_timer(&qc->pto, qc->ctp.max_ack_delay + NGX_QUIC_HARDCODED_PTO); |
3265 qc->ctp.max_ack_delay + NGX_QUIC_HARDCODED_PTO); | |
3266 } | 3265 } |
3267 | 3266 |
3268 return NGX_OK; | 3267 return NGX_OK; |
3269 } | 3268 } |
3270 | 3269 |
3541 } | 3540 } |
3542 } | 3541 } |
3543 | 3542 |
3544 | 3543 |
3545 static void | 3544 static void |
3546 ngx_quic_retransmit_handler(ngx_event_t *ev) | 3545 ngx_quic_pto_handler(ngx_event_t *ev) |
3547 { | 3546 { |
3548 ngx_uint_t i; | 3547 ngx_uint_t i; |
3549 ngx_msec_t wait, nswait; | 3548 ngx_msec_t wait, nswait; |
3550 ngx_connection_t *c; | 3549 ngx_connection_t *c; |
3551 ngx_quic_connection_t *qc; | 3550 ngx_quic_connection_t *qc; |
3552 | 3551 |
3553 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, | 3552 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer"); |
3554 "quic retransmit timer"); | |
3555 | 3553 |
3556 c = ev->data; | 3554 c = ev->data; |
3557 qc = c->quic; | 3555 qc = c->quic; |
3558 | 3556 |
3559 wait = 0; | 3557 wait = 0; |
3560 | 3558 |
3561 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { | 3559 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
3562 if (ngx_quic_retransmit(c, &qc->send_ctx[i], &nswait) != NGX_OK) { | 3560 if (ngx_quic_detect_lost(c, &qc->send_ctx[i], &nswait) != NGX_OK) { |
3563 ngx_quic_close_connection(c, NGX_ERROR); | 3561 ngx_quic_close_connection(c, NGX_ERROR); |
3564 return; | 3562 return; |
3565 } | 3563 } |
3566 | 3564 |
3567 if (i == 0) { | 3565 if (i == 0) { |
3571 wait = nswait; | 3569 wait = nswait; |
3572 } | 3570 } |
3573 } | 3571 } |
3574 | 3572 |
3575 if (wait > 0) { | 3573 if (wait > 0) { |
3576 ngx_add_timer(&qc->retransmit, wait); | 3574 ngx_add_timer(&qc->pto, wait); |
3577 } | 3575 } |
3578 } | 3576 } |
3579 | 3577 |
3580 | 3578 |
3581 static void | 3579 static void |
3593 } | 3591 } |
3594 } | 3592 } |
3595 | 3593 |
3596 | 3594 |
3597 static ngx_int_t | 3595 static ngx_int_t |
3598 ngx_quic_retransmit(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, | 3596 ngx_quic_detect_lost(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
3599 ngx_msec_t *waitp) | 3597 ngx_msec_t *waitp) |
3600 { | 3598 { |
3601 uint64_t pn; | 3599 uint64_t pn; |
3602 ngx_msec_t now, wait; | 3600 ngx_msec_t now, wait; |
3603 ngx_queue_t *q, range; | 3601 ngx_queue_t *q, range; |