Mercurial > hg > nginx
changeset 9003:6c1dfd072859 quic
QUIC: switch stream to DATA_RECVD state.
The switch happens when received byte counter reaches stream final size.
Previously, this state was skipped. The stream went from SIZE_KNOWN to
DATA_READ when all bytes were read by application.
The change prevents STOP_SENDING frames from being sent when all data is
received from client, but not yet fully read by application.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 03 Feb 2022 18:11:59 +0300 |
parents | 740e8b99519d |
children | dde5cb0205ef |
files | src/event/quic/ngx_event_quic.h src/event/quic/ngx_event_quic_streams.c |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic.h +++ b/src/event/quic/ngx_event_quic.h @@ -82,6 +82,7 @@ struct ngx_quic_stream_s { uint64_t recv_offset; uint64_t recv_window; uint64_t recv_last; + uint64_t recv_size; uint64_t final_size; ngx_chain_t *in; ngx_chain_t *out;
--- a/src/event/quic/ngx_event_quic_streams.c +++ b/src/event/quic/ngx_event_quic_streams.c @@ -762,7 +762,7 @@ ngx_quic_stream_recv(ngx_connection_t *c if (len == 0) { rev->ready = 0; - if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN + if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_RECVD && qs->recv_offset == qs->final_size) { qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; @@ -1018,6 +1018,7 @@ ngx_int_t ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, ngx_quic_frame_t *frame) { + size_t size; uint64_t last; ngx_connection_t *sc; ngx_quic_stream_t *qs; @@ -1089,12 +1090,20 @@ ngx_quic_handle_stream_frame(ngx_connect } if (ngx_quic_write_chain(c, &qs->in, frame->data, f->length, - f->offset - qs->recv_offset, NULL) + f->offset - qs->recv_offset, &size) == NGX_CHAIN_ERROR) { return NGX_ERROR; } + qs->recv_size += size; + + if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN + && qs->recv_size == qs->final_size) + { + qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_RECVD; + } + if (f->offset == qs->recv_offset) { ngx_quic_set_event(sc->read); }