diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-03-22 21:04:57 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-04-10 18:47:14 +0300 |
commit | 6f9f546406820dc9e233380e061081c9bcd1de0b (patch) | |
tree | 7140f3b3469890956a326044e1f90da4153117e2 /src/inspector_agent.cc | |
parent | 32e3a6bb87f2f88b8f54ff9e9f216aa5f5f0a647 (diff) |
src: use env->RequestInterrupt() for inspector MainThreadInterface
This simplifies the code significantly, and removes the dependency of
the inspector code on the availability of a `MultiIsolatePlatform`
(by removing the dependency on a platform altogether).
It also fixes a memory leak that occurs when `RequestInterrupt()`
is used, but the interrupt handler is never called before the Isolate
is destroyed.
One downside is that this leads to a slight change in timing, because
inspector messages are not dispatched in a re-entrant way. This means
having to harden one test to account for that possibility by making
sure that the stack is always clear through a `setImmediate()`.
This does not affect the assertion made by the test, which is that
messages will not be delivered synchronously while other code is
executing.
https://github.com/nodejs/node/issues/32415
PR-URL: https://github.com/nodejs/node/pull/32523
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r-- | src/inspector_agent.cc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 8e598c7d1cc..74b7fc13cde 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -662,8 +662,7 @@ class NodeInspectorClient : public V8InspectorClient { std::shared_ptr<MainThreadHandle> getThreadHandle() { if (!interface_) { interface_ = std::make_shared<MainThreadInterface>( - env_->inspector_agent(), env_->event_loop(), env_->isolate(), - env_->isolate_data()->platform()); + env_->inspector_agent()); } return interface_->GetHandle(); } @@ -699,10 +698,9 @@ class NodeInspectorClient : public V8InspectorClient { running_nested_loop_ = true; - MultiIsolatePlatform* platform = env_->isolate_data()->platform(); while (shouldRunMessageLoop()) { if (interface_) interface_->WaitForFrontendEvent(); - while (platform->FlushForegroundTasks(env_->isolate())) {} + env_->RunAndClearInterrupts(); } running_nested_loop_ = false; } |