Mercurial > hg > nginx
diff src/event/quic/ngx_event_quic_frames.c @ 9012:489c2dcb3180 quic
QUIC: trim input chain in ngx_quic_buffer_write().
This allows to eliminate explicit trimming when handling input STREAM frame.
As a result, ngx_quic_trim_chain() is eliminated as well.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 14 Feb 2022 14:51:10 +0300 |
parents | f9c788f3f5cc |
children | b5656025ddb5 |
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic_frames.c Mon Feb 14 15:27:59 2022 +0300 +++ b/src/event/quic/ngx_event_quic_frames.c Mon Feb 14 14:51:10 2022 +0300 @@ -259,26 +259,6 @@ void -ngx_quic_trim_chain(ngx_chain_t *in, size_t size) -{ - size_t n; - ngx_buf_t *b; - - while (in && size > 0) { - b = in->buf; - n = ngx_min((size_t) (b->last - b->pos), size); - - b->pos += n; - size -= n; - - if (b->pos == b->last) { - in = in->next; - } - } -} - - -void ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in) { ngx_chain_t *cl; @@ -551,6 +531,22 @@ chain = &qb->chain; while (in && limit) { + + if (offset < base) { + n = ngx_min((uint64_t) (in->buf->last - in->buf->pos), + ngx_min(base - offset, limit)); + + in->buf->pos += n; + offset += n; + limit -= n; + + if (in->buf->pos == in->buf->last) { + in = in->next; + } + + continue; + } + cl = *chain; if (cl == NULL) {