http2: force through RST_STREAM in destroy by apapirovski · Pull Request #21016 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/internal/http2/core.js
2 changes: 2 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,8 @@ void Http2Stream::Destroy() {
// Do nothing if this stream instance is already destroyed
if (IsDestroyed())
return;
if (session_->HasPendingRstStream(id_))
FlushRstStream();
flags_ |= NGHTTP2_STREAM_FLAG_DESTROYED;

DEBUG_HTTP2STREAM(this, "destroying stream");
Expand Down
7 changes: 7 additions & 0 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "stream_base-inl.h"
#include "string_bytes.h"

#include <algorithm>
#include <queue>

namespace node {
Expand Down Expand Up @@ -855,6 +856,12 @@ class Http2Session : public AsyncWrap, public StreamListener {
pending_rst_streams_.emplace_back(stream_id);
}

inline bool HasPendingRstStream(int32_t stream_id) {
return pending_rst_streams_.end() != std::find(pending_rst_streams_.begin(),
pending_rst_streams_.end(),
stream_id);
}

// Handle reads/writes from the underlying network transport.
void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
void OnStreamAfterWrite(WriteWrap* w, int status) override;
Expand Down
40 changes: 40 additions & 0 deletions test/parallel/test-http2-large-write-destroy.js