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.
This commit is contained in:
parent
8363d84edd
commit
45c5af421b
3 changed files with 16 additions and 26 deletions
|
@ -258,26 +258,6 @@ ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame)
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -551,6 +531,22 @@ ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
|
|||
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) {
|
||||
|
|
|
@ -26,7 +26,6 @@ ngx_int_t ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f,
|
|||
ngx_chain_t *ngx_quic_alloc_chain(ngx_connection_t *c);
|
||||
ngx_chain_t *ngx_quic_copy_buf(ngx_connection_t *c, u_char *data,
|
||||
size_t len);
|
||||
void ngx_quic_trim_chain(ngx_chain_t *in, size_t size);
|
||||
void ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in);
|
||||
|
||||
ngx_chain_t *ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
|
||||
|
|
|
@ -1115,11 +1115,6 @@ ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
|
|||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (f->offset < qs->recv_offset) {
|
||||
ngx_quic_trim_chain(frame->data, qs->recv_offset - f->offset);
|
||||
f->offset = qs->recv_offset;
|
||||
}
|
||||
|
||||
if (f->fin) {
|
||||
if (qs->recv_final_size != (uint64_t) -1 && qs->recv_final_size != last)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue