Skip to content

Commit def8e76

Browse files
committed
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: #34137 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent d603418 commit def8e76

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/quic/node_quic_stream-inl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ void QuicStream::set_flag(int32_t flag, bool on) {
3535
}
3636

3737
void QuicStream::set_final_size(uint64_t final_size) {
38-
CHECK_EQ(GetStat(&QuicStreamStats::final_size), 0);
38+
// Only set the final size once.
39+
if (is_flag_set(QUICSTREAM_FLAG_FIN)) {
40+
CHECK_LE(final_size, GetStat(&QuicStreamStats::final_size));
41+
return;
42+
}
43+
set_flag(QUICSTREAM_FLAG_FIN);
3944
SetStat(&QuicStreamStats::final_size, final_size);
4045
}
4146

src/quic/node_quic_stream.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ void QuicStream::ReceiveData(
355355
// When fin != 0, we've received that last chunk of data for this
356356
// stream, indicating that the stream will no longer be readable.
357357
if (flags & NGTCP2_STREAM_DATA_FLAG_FIN) {
358-
set_flag(QUICSTREAM_FLAG_FIN);
359358
set_final_size(offset + datalen);
360359
EmitRead(UV_EOF);
361360
}

src/quic/node_quic_stream.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ class QuicStream : public AsyncWrap,
256256
// Specifies the kind of headers currently being processed.
257257
inline void set_headers_kind(QuicStreamHeadersKind kind);
258258

259-
// Set the final size for the QuicStream
259+
// Set the final size for the QuicStream. This only works
260+
// the first time it is called. Subsequent calls will be
261+
// ignored unless the subsequent size is greater than the
262+
// prior set size, in which case we have a bug and we'll
263+
// assert.
260264
inline void set_final_size(uint64_t final_size);
261265

262266
// The final size is the maximum amount of data that has been

0 commit comments

Comments
 (0)