Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1724a4e
src: add optional keep-alive object to SetImmediate
addaleax Nov 21, 2017
df31133
http2: don't call into JS from GC
addaleax Nov 21, 2017
8c28e30
http2: only schedule write when necessary
addaleax Nov 21, 2017
504ee24
http2: be sure to destroy the Http2Stream
jasnell Nov 27, 2017
ac89b78
http2: cleanup Http2Stream/Http2Session destroy
jasnell Dec 12, 2017
7ab5c62
http2: remove redundant write indirection
addaleax Dec 17, 2017
66be8e5
http2: refactor outgoing write mechanism
addaleax Dec 17, 2017
293c2f9
http2: convert Http2Settings to an AsyncWrap
jasnell Dec 18, 2017
08478c1
http2: fix compiling with `--debug-http2`
addaleax Dec 25, 2017
b61c3fc
http2: keep session objects alive during Http2Scope
addaleax Dec 25, 2017
afa4a7c
http2: implement ref() and unref() on client sessions
kjin Dec 11, 2017
8d8dfea
http2: remove duplicate words in comments
tniessen Jan 1, 2018
d968c02
http2: perf_hooks integration
jasnell Dec 20, 2017
bf7eed3
http2: strictly limit number on concurrent streams
jasnell Nov 21, 2017
8df5d02
http2: add altsvc support
jasnell Dec 29, 2017
ae4e308
tls: set servername on client side too
jasnell Jan 1, 2018
7d6aa20
http2: add initial support for originSet
jasnell Jan 1, 2018
760f678
http2: add aligned padding strategy
jasnell Jan 1, 2018
06ed513
http2: properly handle already closed stream error
jasnell Jan 2, 2018
e929bd0
doc: add docs for common/http2.js utility
jasnell Jan 2, 2018
c1c4a6c
src: silence http2 -Wunused-result warnings
cjihrig Jan 2, 2018
adbc38a
http2: implement maxSessionMemory
jasnell Jan 3, 2018
51dc318
http2: verify that a dependency cycle may exist
jasnell Jan 3, 2018
d1e75eb
doc: grammar fixes in http2.md
Trott Jan 4, 2018
cd6fcf3
http2: verify flood error and unsolicited frames
jasnell Jan 3, 2018
526cf84
doc: correct spelling
sreepurnajasti Dec 29, 2017
d7dd941
perf_hooks: fix scheduling regression
apapirovski Jan 9, 2018
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
Prev Previous commit
Next Next commit
http2: keep session objects alive during Http2Scope
Keep a local handle as a reference to the JS `Http2Session`
object so that it will not be garbage collected
when inside an `Http2Scope`, because the presence of the
latter usually indicates that further actions on
the session object are expected.

Strictly speaking, storing the `session_handle_` as a
property on the scope object is not necessary, but
this is not very costly and makes the code more
obviously correct.

Fixes: #17840

PR-URL: #17863
Fixes: #17840
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Jan 9, 2018
commit b61c3fc2b7beab41cbe5b54043056045f80bd8b4
7 changes: 7 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Http2Scope::Http2Scope(Http2Session* session) {
}
session->flags_ |= SESSION_STATE_HAS_SCOPE;
session_ = session;

// Always keep the session object alive for at least as long as
// this scope is active.
session_handle_ = session->object();
CHECK(!session_handle_.IsEmpty());
}

Http2Scope::~Http2Scope() {
Expand Down Expand Up @@ -512,6 +517,7 @@ void Http2Session::Unconsume() {
}

Http2Session::~Http2Session() {
CHECK_EQ(flags_ & SESSION_STATE_HAS_SCOPE, 0);
if (!object().IsEmpty())
ClearWrap(object());
persistent().Reset();
Expand Down Expand Up @@ -1365,6 +1371,7 @@ void Http2Session::OnStreamReadImpl(ssize_t nread,
void* ctx) {
Http2Session* session = static_cast<Http2Session*>(ctx);
Http2Scope h2scope(session);
CHECK_NE(session->stream_, nullptr);
DEBUG_HTTP2SESSION2(session, "receiving %d bytes", nread);
if (nread < 0) {
uv_buf_t tmp_buf;
Expand Down
1 change: 1 addition & 0 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class Http2Scope {

private:
Http2Session* session_ = nullptr;
Local<Object> session_handle_;
};

// The Http2Options class is used to parse the options object passed in to
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-http2-createwritereq.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

// Flags: --expose-gc

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
Expand Down Expand Up @@ -62,6 +64,15 @@ server.listen(0, common.mustCall(function() {
}
}));

// Ref: https://github.com/nodejs/node/issues/17840
const origDestroy = req.destroy;
req.destroy = function(...args) {
// Schedule a garbage collection event at the end of the current
// MakeCallback() run.
process.nextTick(global.gc);
return origDestroy.call(this, ...args);
};

req.end();
});
}));