aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2020-03-23 21:20:20 +0300
committerRoman Arutyunyan <arut@nginx.com>2020-03-23 21:20:20 +0300
commit5ac5e51fdfe68e8b11f8c7abd2ce361062f68e54 (patch)
treeab1290524b9a99dc37162c4b45bb9bbad98ad2f9
parent9975b088bbd24af0f0543bb921a1313a285da319 (diff)
downloadnginx-5ac5e51fdfe68e8b11f8c7abd2ce361062f68e54.tar.gz
nginx-5ac5e51fdfe68e8b11f8c7abd2ce361062f68e54.zip
Respect QUIC max_idle_timeout.
-rw-r--r--src/event/ngx_event_quic.c33
-rw-r--r--src/event/ngx_event_quic.h2
-rw-r--r--src/http/ngx_http_request.c4
-rw-r--r--src/http/v3/ngx_http_v3_module.c2
4 files changed, 27 insertions, 14 deletions
diff --git a/src/event/ngx_event_quic.c b/src/event/ngx_event_quic.c
index 582d3f8ce..a4a293a14 100644
--- 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_t *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_conn, enum ssl_encryption_level_t level,
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_ssl_t *ssl, ngx_quic_tp_t *tp,
// 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_t *c)
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;
}
diff --git a/src/event/ngx_event_quic.h b/src/event/ngx_event_quic.h
index c174bfe44..1f022c678 100644
--- 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);
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6c9fdc543..acd708cf6 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -347,9 +347,7 @@ ngx_http_init_connection(ngx_connection_t *c)
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
diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c
index 385838df4..45bfc5b1c 100644
--- 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 *cf, void *parent, void *child)
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,