Mercurial > hg > nginx
diff src/event/quic/ngx_event_quic_transport.c @ 8698:9ed95726b99b quic
QUIC: send PING frames on PTO expiration.
Two PING frames are sent per level that generate two UDP datagrams.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 12 Feb 2021 14:51:53 +0300 |
parents | 0697294f79a4 |
children | e24e5650d7b4 |
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic_transport.c Fri Feb 12 14:40:33 2021 +0300 +++ b/src/event/quic/ngx_event_quic_transport.c Fri Feb 12 14:51:53 2021 +0300 @@ -93,6 +93,7 @@ static ngx_int_t ngx_quic_frame_allowed(ngx_quic_header_t *pkt, ngx_uint_t frame_type); +static size_t ngx_quic_create_ping(u_char *p); static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack, ngx_chain_t *ranges); static size_t ngx_quic_create_stop_sending(u_char *p, @@ -1220,6 +1221,9 @@ f->need_ack = 1; switch (f->type) { + case NGX_QUIC_FT_PING: + return ngx_quic_create_ping(p); + case NGX_QUIC_FT_ACK: f->need_ack = 0; return ngx_quic_create_ack(p, &f->u.ack, f->data); @@ -1277,6 +1281,23 @@ static size_t +ngx_quic_create_ping(u_char *p) +{ + u_char *start; + + if (p == NULL) { + return ngx_quic_varint_len(NGX_QUIC_FT_PING); + } + + start = p; + + ngx_quic_build_int(&p, NGX_QUIC_FT_PING); + + return p - start; +} + + +static size_t ngx_quic_create_ack(u_char *p, ngx_quic_ack_frame_t *ack, ngx_chain_t *ranges) { size_t len;