http2: force through RST_STREAM in destroy · nodejs/node@b22266c · GitHub
Skip to content

Commit b22266c

Browse files
apapirovskiBethGriggs
authored andcommitted
http2: force through RST_STREAM in destroy
If still needed, force through RST_STREAM in Http2Stream#destroy calls, so that nghttp2 can wrap up properly and doesn't continue trying to read & write data to the stream. Backport-PR-URL: #22850 PR-URL: #21016 Fixes: #21008 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 91be1dc commit b22266c

4 files changed

Lines changed: 59 additions & 5 deletions

File tree

lib/internal/http2/core.js

Lines changed: 10 additions & 5 deletions

src/node_http2.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,8 @@ inline void Http2Stream::Destroy() {
18391839
// Do nothing if this stream instance is already destroyed
18401840
if (IsDestroyed())
18411841
return;
1842+
if (session_->HasPendingRstStream(id_))
1843+
FlushRstStream();
18421844
flags_ |= NGHTTP2_STREAM_FLAG_DESTROYED;
18431845

18441846
DEBUG_HTTP2STREAM(this, "destroying stream");

src/node_http2.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "stream_base-inl.h"
1010
#include "string_bytes.h"
1111

12+
#include <algorithm>
1213
#include <queue>
1314

1415
namespace node {
@@ -880,6 +881,12 @@ class Http2Session : public AsyncWrap {
880881
pending_rst_streams_.emplace_back(stream_id);
881882
}
882883

884+
inline bool HasPendingRstStream(int32_t stream_id) {
885+
return pending_rst_streams_.end() != std::find(pending_rst_streams_.begin(),
886+
pending_rst_streams_.end(),
887+
stream_id);
888+
}
889+
883890
static void OnStreamAllocImpl(size_t suggested_size,
884891
uv_buf_t* buf,
885892
void* ctx);
Lines changed: 40 additions & 0 deletions

0 commit comments

Comments
 (0)