Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
quic: fixup ResetStream
Browse files Browse the repository at this point in the history
cancel stream buffer after sending reset to avoid segfault

PR-URL: #341
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
jasnell committed Feb 12, 2020
1 parent 29740b2 commit 32c587d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/quic/node_quic_stream-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ void QuicStream::ResetStream(uint64_t app_error_code) {
// streambuf_ will be canceled, and all data pending
// to be acknowledged at the ngtcp2 level will be
// abandoned.
BaseObjectPtr<QuicSession> ptr(session_);
set_flag(QUICSTREAM_FLAG_READ_CLOSED);
session_->ResetStream(stream_id_, app_error_code);
streambuf_.Cancel();
streambuf_.End();
session_->ResetStream(stream_id_, app_error_code);
}

void QuicStream::Schedule(Queue* queue) {
Expand Down
3 changes: 0 additions & 3 deletions test/parallel/test-quic-quicstream-close-early.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ server.on('ready', common.mustCall(() => {

const stream = req.openStream();

// TODO(@jasnell): The close happens synchronously, before any
// data for the stream is actually flushed out to the connected
// peer.
stream.write('hello', common.mustCall());
stream.close(1);

Expand Down

0 comments on commit 32c587d

Please sign in to comment.