Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic_streams.c @ 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 | 7626aa7a2156 |
children | e56a05d6dbd1 |
comparison
equal
deleted
inserted
replaced
9002:740e8b99519d | 9003:6c1dfd072859 |
---|---|
760 ngx_quic_free_chain(pc, in); | 760 ngx_quic_free_chain(pc, in); |
761 | 761 |
762 if (len == 0) { | 762 if (len == 0) { |
763 rev->ready = 0; | 763 rev->ready = 0; |
764 | 764 |
765 if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN | 765 if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_RECVD |
766 && qs->recv_offset == qs->final_size) | 766 && qs->recv_offset == qs->final_size) |
767 { | 767 { |
768 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; | 768 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
769 } | 769 } |
770 | 770 |
1016 | 1016 |
1017 ngx_int_t | 1017 ngx_int_t |
1018 ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, | 1018 ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
1019 ngx_quic_frame_t *frame) | 1019 ngx_quic_frame_t *frame) |
1020 { | 1020 { |
1021 size_t size; | |
1021 uint64_t last; | 1022 uint64_t last; |
1022 ngx_connection_t *sc; | 1023 ngx_connection_t *sc; |
1023 ngx_quic_stream_t *qs; | 1024 ngx_quic_stream_t *qs; |
1024 ngx_quic_connection_t *qc; | 1025 ngx_quic_connection_t *qc; |
1025 ngx_quic_stream_frame_t *f; | 1026 ngx_quic_stream_frame_t *f; |
1087 qs->final_size = last; | 1088 qs->final_size = last; |
1088 qs->recv_state = NGX_QUIC_STREAM_RECV_SIZE_KNOWN; | 1089 qs->recv_state = NGX_QUIC_STREAM_RECV_SIZE_KNOWN; |
1089 } | 1090 } |
1090 | 1091 |
1091 if (ngx_quic_write_chain(c, &qs->in, frame->data, f->length, | 1092 if (ngx_quic_write_chain(c, &qs->in, frame->data, f->length, |
1092 f->offset - qs->recv_offset, NULL) | 1093 f->offset - qs->recv_offset, &size) |
1093 == NGX_CHAIN_ERROR) | 1094 == NGX_CHAIN_ERROR) |
1094 { | 1095 { |
1095 return NGX_ERROR; | 1096 return NGX_ERROR; |
1097 } | |
1098 | |
1099 qs->recv_size += size; | |
1100 | |
1101 if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN | |
1102 && qs->recv_size == qs->final_size) | |
1103 { | |
1104 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_RECVD; | |
1096 } | 1105 } |
1097 | 1106 |
1098 if (f->offset == qs->recv_offset) { | 1107 if (f->offset == qs->recv_offset) { |
1099 ngx_quic_set_event(sc->read); | 1108 ngx_quic_set_event(sc->read); |
1100 } | 1109 } |