QUIC: fixed insertion at the end of buffer.

Previously, last buffer was tracked by keeping a pointer to the previous
chain link "next" field.  When the previous buffer was split and then removed,
the pointer was no longer valid.  Writing at this pointer resulted in broken
data chains.

Now last buffer is tracked by keeping a direct pointer to it.
This commit is contained in:
Roman Arutyunyan 2022-02-17 22:38:42 +03:00
parent 4ce2114724
commit c5f5a571d9
2 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ typedef struct {
uint64_t offset;
uint64_t last_offset;
ngx_chain_t *chain;
ngx_chain_t **last_chain;
ngx_chain_t *last_chain;
} ngx_quic_buffer_t;

View File

@ -503,7 +503,7 @@ ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
if (qb->last_chain && offset >= qb->last_offset) {
base = qb->last_offset;
chain = qb->last_chain;
chain = &qb->last_chain;
} else {
base = qb->offset;
@ -600,7 +600,7 @@ ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
}
qb->last_offset = base;
qb->last_chain = chain;
qb->last_chain = *chain;
return in;
}