Mercurial > hg > nginx-quic
changeset 7737:8e54a17dabee quic
Respect QUIC max_idle_timeout.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 23 Mar 2020 21:20:20 +0300 |
parents | c87a13514abc |
children | 7f0981be07c4 |
files | src/event/ngx_event_quic.c src/event/ngx_event_quic.h src/http/ngx_http_request.c src/http/v3/ngx_http_v3_module.c |
diffstat | 4 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c +++ b/src/event/ngx_event_quic.c @@ -30,7 +30,6 @@ typedef struct { typedef struct { ngx_rbtree_t tree; ngx_rbtree_node_t sentinel; - ngx_msec_t timeout; ngx_connection_handler_pt handler; ngx_uint_t id_counter; @@ -59,6 +58,8 @@ struct ngx_quic_connection_s { ngx_quic_streams_t streams; ngx_uint_t max_data; + ngx_uint_t send_timer_set; + /* unsigned send_timer_set:1 */ #define SSL_ECRYPTION_LAST ((ssl_encryption_application) + 1) uint64_t crypto_offset[SSL_ECRYPTION_LAST]; @@ -255,6 +256,12 @@ ngx_quic_add_handshake_data(ngx_ssl_conn return NGX_ERROR; } + if (qc->ctp.max_idle_timeout > 0 + && qc->ctp.max_idle_timeout < qc->tp.max_idle_timeout) + { + qc->tp.max_idle_timeout = qc->ctp.max_idle_timeout; + } + qc->client_tp_done = 1; } } @@ -334,7 +341,7 @@ ngx_quic_send_alert(ngx_ssl_conn_t *ssl_ void ngx_quic_run(ngx_connection_t *c, ngx_ssl_t *ssl, ngx_quic_tp_t *tp, - ngx_msec_t timeout, ngx_connection_handler_pt handler) + ngx_connection_handler_pt handler) { ngx_buf_t *b; ngx_quic_header_t pkt; @@ -359,9 +366,8 @@ ngx_quic_run(ngx_connection_t *c, ngx_ss // we don't need stream handler for initial packet processing c->quic->streams.handler = handler; - c->quic->streams.timeout = timeout; - ngx_add_timer(c->read, timeout); + ngx_add_timer(c->read, c->quic->tp.max_idle_timeout); c->read->handler = ngx_quic_input_handler; @@ -524,9 +530,10 @@ ngx_quic_init_connection(ngx_connection_ static void ngx_quic_input_handler(ngx_event_t *rev) { - ssize_t n; - ngx_buf_t b; - ngx_connection_t *c; + ssize_t n; + ngx_buf_t b; + ngx_connection_t *c; + ngx_quic_connection_t *qc; static u_char buf[65535]; @@ -544,8 +551,6 @@ ngx_quic_input_handler(ngx_event_t *rev) return; } - ngx_add_timer(rev, c->quic->streams.timeout); - if (c->close) { ngx_quic_close_connection(c); return; @@ -569,6 +574,11 @@ ngx_quic_input_handler(ngx_event_t *rev) ngx_quic_close_connection(c); return; } + + qc = c->quic; + + qc->send_timer_set = 0; + ngx_add_timer(rev, qc->tp.max_idle_timeout); } @@ -1209,6 +1219,11 @@ ngx_quic_output(ngx_connection_t *c) qc->frames = NULL; + if (!qc->send_timer_set) { + qc->send_timer_set = 1; + ngx_add_timer(c->read, qc->tp.max_idle_timeout); + } + return NGX_OK; }
--- a/src/event/ngx_event_quic.h +++ b/src/event/ngx_event_quic.h @@ -54,7 +54,7 @@ struct ngx_quic_stream_s { void ngx_quic_run(ngx_connection_t *c, ngx_ssl_t *ssl, ngx_quic_tp_t *tp, - ngx_msec_t timeout, ngx_connection_handler_pt handler); + ngx_connection_handler_pt handler); ngx_connection_t *ngx_quic_create_uni_stream(ngx_connection_t *c);
--- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -347,9 +347,7 @@ ngx_http_init_connection(ngx_connection_ v3cf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module); sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); - ngx_quic_run(c, &sscf->ssl, &v3cf->quic, - c->listening->post_accept_timeout, - ngx_http_quic_stream_handler); + ngx_quic_run(c, &sscf->ssl, &v3cf->quic, ngx_http_quic_stream_handler); return; } #endif
--- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -229,7 +229,7 @@ ngx_http_v3_merge_srv_conf(ngx_conf_t *c ngx_http_v3_srv_conf_t *conf = child; ngx_conf_merge_msec_value(conf->quic.max_idle_timeout, - prev->quic.max_idle_timeout, 10000); + prev->quic.max_idle_timeout, 60000); // > 2 ^ 14 is invalid ngx_conf_merge_msec_value(conf->quic.max_ack_delay,