diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-10 19:47:03 +0000 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-03-21 10:57:08 +0100 |
commit | d7bc5816a5d88e18d7ede081042d87f48a2bc54b (patch) | |
tree | f8b5c540eb6a127aeac87b3c0f37e99655ed8f2f /src/node_platform.cc | |
parent | 78a2dc7de2139cc51cf4992da7d835eed0b69c32 (diff) | |
download | node-new-d7bc5816a5d88e18d7ede081042d87f48a2bc54b.tar.gz |
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_platform.cc')
-rw-r--r-- | src/node_platform.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/node_platform.cc b/src/node_platform.cc index 740ace1fb7..7628cf5339 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -421,6 +421,7 @@ void PerIsolatePlatformData::RunForegroundTask(uv_timer_t* handle) { void NodePlatform::DrainTasks(Isolate* isolate) { std::shared_ptr<PerIsolatePlatformData> per_isolate = ForNodeIsolate(isolate); + if (!per_isolate) return; do { // Worker tasks aren't associated with an Isolate. @@ -489,12 +490,14 @@ std::shared_ptr<PerIsolatePlatformData> NodePlatform::ForNodeIsolate(Isolate* isolate) { Mutex::ScopedLock lock(per_isolate_mutex_); auto data = per_isolate_[isolate]; - CHECK(data.second); + CHECK_NOT_NULL(data.first); return data.second; } bool NodePlatform::FlushForegroundTasks(Isolate* isolate) { - return ForNodeIsolate(isolate)->FlushForegroundTasksInternal(); + std::shared_ptr<PerIsolatePlatformData> per_isolate = ForNodeIsolate(isolate); + if (!per_isolate) return false; + return per_isolate->FlushForegroundTasksInternal(); } bool NodePlatform::IdleTasksEnabled(Isolate* isolate) { |