Skip to content

Commit

Permalink
http2: don't call into JS from GC
Browse files Browse the repository at this point in the history
Calling into JS land from GC is not allowed, so delay
the resolution of pending pings when a session is destroyed.

Backport-PR-URL: #18050
PR-URL: #17183
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Jan 10, 2018
1 parent 7e68080 commit d06ad0d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ void Http2Session::Close() {

while (!outstanding_pings_.empty()) {
Http2Session::Http2Ping* ping = PopPing();
ping->Done(false);
// Since this method may be called from GC, calling into JS directly
// is not allowed.
env()->SetImmediate([](Environment* env, void* data) {
static_cast<Http2Session::Http2Ping*>(data)->Done(false);
}, static_cast<void*>(ping));
}

Stop();
Expand Down

0 comments on commit d06ad0d

Please sign in to comment.