Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-11-10 22:47:03 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-21 12:57:08 +0300
commitd7bc5816a5d88e18d7ede081042d87f48a2bc54b (patch)
treef8b5c540eb6a127aeac87b3c0f37e99655ed8f2f /src/node_worker.cc
parent78a2dc7de2139cc51cf4992da7d835eed0b69c32 (diff)
src: make `FreeEnvironment()` perform all necessary cleanup
Make the calls `stop_sub_worker_contexts()`, `RunCleanup()` part of the public API for easier embedding. (Note that calling `RunAtExit()` is idempotent because the at-exit callback queue is cleared after each call.) PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r--src/node_worker.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 6ff1a0afe99..1e1877e026c 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -270,26 +270,18 @@ void Worker::Run() {
auto cleanup_env = OnScopeLeave([&]() {
if (!env_) return;
env_->set_can_call_into_js(false);
- Isolate::DisallowJavascriptExecutionScope disallow_js(isolate_,
- Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
{
- Context::Scope context_scope(env_->context());
- {
- Mutex::ScopedLock lock(mutex_);
- stopped_ = true;
- this->env_ = nullptr;
- }
- env_->set_stopping(true);
- env_->stop_sub_worker_contexts();
- env_->RunCleanup();
- RunAtExit(env_.get());
-
- // This call needs to be made while the `Environment` is still alive
- // because we assume that it is available for async tracking in the
- // NodePlatform implementation.
- platform_->DrainTasks(isolate_);
+ Mutex::ScopedLock lock(mutex_);
+ stopped_ = true;
+ this->env_ = nullptr;
}
+
+ // TODO(addaleax): Try moving DisallowJavascriptExecutionScope into
+ // FreeEnvironment().
+ Isolate::DisallowJavascriptExecutionScope disallow_js(isolate_,
+ Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
+ env_.reset();
});
if (is_stopped()) return;