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.

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 committed Nov 27, 2017
1 parent 7306a33 commit 10d86d2
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 10d86d2

Please sign in to comment.