diff options
| author | Roman Arutyunyan <arut@nginx.com> | 2022-02-14 14:54:34 +0300 |
|---|---|---|
| committer | Roman Arutyunyan <arut@nginx.com> | 2022-02-14 14:54:34 +0300 |
| commit | cac8623697fadd1a42134ca3af8d0c55c9b755b7 (patch) | |
| tree | 764762091b2a91c8bde5aad695041eaf5cc63ad4 /src/event/quic/ngx_event_quic_frames.c | |
| parent | f15459fc466b12e3c1591b4d0a06c113f7a591c5 (diff) | |
| download | nginx-cac8623697fadd1a42134ca3af8d0c55c9b755b7.tar.gz nginx-cac8623697fadd1a42134ca3af8d0c55c9b755b7.tar.bz2 | |
QUIC: optimize insertion at the end of QUIC buffer.
Diffstat (limited to 'src/event/quic/ngx_event_quic_frames.c')
| -rw-r--r-- | src/event/quic/ngx_event_quic_frames.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/event/quic/ngx_event_quic_frames.c b/src/event/quic/ngx_event_quic_frames.c index c6d8de74e..5ffae32c3 100644 --- a/src/event/quic/ngx_event_quic_frames.c +++ b/src/event/quic/ngx_event_quic_frames.c @@ -421,6 +421,10 @@ ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, uint64_t limit) qb->offset += n; } + if (qb->offset >= qb->last_offset) { + qb->last_chain = NULL; + } + qb->chain = *ll; *ll = NULL; @@ -462,6 +466,10 @@ ngx_quic_skip_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, if (qb->chain == NULL) { qb->offset = offset; } + + if (qb->offset >= qb->last_offset) { + qb->last_chain = NULL; + } } @@ -493,8 +501,14 @@ ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, ngx_buf_t *b; ngx_chain_t *cl, **chain; - base = qb->offset; - chain = &qb->chain; + if (qb->last_chain && offset >= qb->last_offset) { + base = qb->last_offset; + chain = qb->last_chain; + + } else { + base = qb->offset; + chain = &qb->chain; + } while (in && limit) { @@ -585,6 +599,9 @@ ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, } } + qb->last_offset = base; + qb->last_chain = chain; + return in; } |
