Skip to content

Commit 3e6d717

Browse files
committed
http2: update checks for adding rst_stream to pending list
1 parent f3ea45e commit 3e6d717

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/node_http2.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,11 +2196,13 @@ void Http2Stream::SubmitRstStream(const uint32_t code) {
21962196
CHECK(!this->is_destroyed());
21972197
code_ = code;
21982198

2199-
// If RST_STREAM is submitted with the cancel code, don't force purge the
2200-
// currently sending data. Instead add it to the pending stream list to
2201-
// avoid prioritizing over other operations.
2199+
// If RST_STREAM frame is received and stream is not writable
2200+
// because it is busy reading data, don't try force purging it.
2201+
// Instead add the stream to pending stream list and process
2202+
// the pending data when it is safe to do so. This is to avoid
2203+
// double free error due to unwanted behavior of nghttp2.
22022204
// Ref:https://github.com/nodejs/node/issues/38964
2203-
if (code_ == NGHTTP2_CANCEL) {
2205+
if (!is_writable() && is_reading()) {
22042206
session_->AddPendingRstStream(id_);
22052207
return;
22062208
}

0 commit comments

Comments
 (0)