Skip to content

Commit b8c9048

Browse files
committed
src: shutdown platform from FreePlatform()
There is currently no way to properly do this. Backport-PR-URL: #35241 PR-URL: #30467 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent a28c990 commit b8c9048

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/node_platform.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ NodePlatform::NodePlatform(int thread_pool_size,
333333
std::make_shared<WorkerThreadsTaskRunner>(thread_pool_size);
334334
}
335335

336+
NodePlatform::~NodePlatform() {
337+
Shutdown();
338+
}
339+
336340
void NodePlatform::RegisterIsolate(Isolate* isolate, uv_loop_t* loop) {
337341
Mutex::ScopedLock lock(per_isolate_mutex_);
338342
std::shared_ptr<PerIsolatePlatformData> existing = per_isolate_[isolate];
@@ -362,6 +366,8 @@ void NodePlatform::AddIsolateFinishedCallback(Isolate* isolate,
362366
}
363367

364368
void NodePlatform::Shutdown() {
369+
if (has_shut_down_) return;
370+
has_shut_down_ = true;
365371
worker_thread_task_runner_->Shutdown();
366372

367373
{

src/node_platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class NodePlatform : public MultiIsolatePlatform {
138138
public:
139139
NodePlatform(int thread_pool_size,
140140
v8::TracingController* tracing_controller);
141-
~NodePlatform() override = default;
141+
~NodePlatform() override;
142142

143143
void DrainTasks(v8::Isolate* isolate) override;
144144
void Shutdown();
@@ -181,6 +181,7 @@ class NodePlatform : public MultiIsolatePlatform {
181181

182182
v8::TracingController* tracing_controller_;
183183
std::shared_ptr<WorkerThreadsTaskRunner> worker_thread_task_runner_;
184+
bool has_shut_down_ = false;
184185
};
185186

186187
} // namespace node

0 commit comments

Comments
 (0)