diff options
author | James M Snell <jasnell@gmail.com> | 2020-06-30 09:35:59 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-30 17:50:47 -0700 |
commit | def8e769992332a9373559ecd2058ef4ac8698fa (patch) | |
tree | b1af00aa0fb462581e8fea28e6623ecfbc992f7e /src | |
parent | d6034186d661ab69f33af81f8ce649375dafadd7 (diff) | |
download | node-new-def8e769992332a9373559ecd2058ef4ac8698fa.tar.gz |
quic: fixup set_final_size
Ignore subsequent calls to set_final_size unless the new size
is more than the previous, in which case, we have us a bug.
PR-URL: https://github.com/nodejs/node/pull/34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quic/node_quic_stream-inl.h | 7 | ||||
-rw-r--r-- | src/quic/node_quic_stream.cc | 1 | ||||
-rw-r--r-- | src/quic/node_quic_stream.h | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/quic/node_quic_stream-inl.h b/src/quic/node_quic_stream-inl.h index 3da0f5fb3b..3dd1fc216d 100644 --- a/src/quic/node_quic_stream-inl.h +++ b/src/quic/node_quic_stream-inl.h @@ -35,7 +35,12 @@ void QuicStream::set_flag(int32_t flag, bool on) { } void QuicStream::set_final_size(uint64_t final_size) { - CHECK_EQ(GetStat(&QuicStreamStats::final_size), 0); + // Only set the final size once. + if (is_flag_set(QUICSTREAM_FLAG_FIN)) { + CHECK_LE(final_size, GetStat(&QuicStreamStats::final_size)); + return; + } + set_flag(QUICSTREAM_FLAG_FIN); SetStat(&QuicStreamStats::final_size, final_size); } diff --git a/src/quic/node_quic_stream.cc b/src/quic/node_quic_stream.cc index 7a1054db40..ce8cc78a1e 100644 --- a/src/quic/node_quic_stream.cc +++ b/src/quic/node_quic_stream.cc @@ -355,7 +355,6 @@ void QuicStream::ReceiveData( // When fin != 0, we've received that last chunk of data for this // stream, indicating that the stream will no longer be readable. if (flags & NGTCP2_STREAM_DATA_FLAG_FIN) { - set_flag(QUICSTREAM_FLAG_FIN); set_final_size(offset + datalen); EmitRead(UV_EOF); } diff --git a/src/quic/node_quic_stream.h b/src/quic/node_quic_stream.h index 97174dcb7b..d8297f300b 100644 --- a/src/quic/node_quic_stream.h +++ b/src/quic/node_quic_stream.h @@ -256,7 +256,11 @@ class QuicStream : public AsyncWrap, // Specifies the kind of headers currently being processed. inline void set_headers_kind(QuicStreamHeadersKind kind); - // Set the final size for the QuicStream + // Set the final size for the QuicStream. This only works + // the first time it is called. Subsequent calls will be + // ignored unless the subsequent size is greater than the + // prior set size, in which case we have a bug and we'll + // assert. inline void set_final_size(uint64_t final_size); // The final size is the maximum amount of data that has been |