src: clean up agent loop when exiting through destructor

Fixes: https://github.com/nodejs/node/issues/22042

PR-URL: https://github.com/nodejs/node/pull/21867
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
This commit is contained in:
Anna Henningsen committed 2018-08-01 17:17:06 +02:00
1 parent 5e83a2abd0
commit 281e5a3cee
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -398,10 +398,10 @@ static struct {
}
void Dispose() {
tracing_agent_.reset(nullptr);
platform_->Shutdown();
delete platform_;
platform_ = nullptr;
tracing_agent_.reset(nullptr);
}
void DrainVMTasks(Isolate* isolate) {
+6
View File
@@ -59,6 +59,7 @@ Agent::Agent() {
Agent* agent = ContainerOf(&Agent::initialize_writer_async_, async);
agent->InitializeWritersOnThread();
}), 0);
uv_unref(reinterpret_cast<uv_handle_t*>(&initialize_writer_async_));
}
void Agent::InitializeWritersOnThread() {
@@ -72,6 +73,11 @@ void Agent::InitializeWritersOnThread() {
}
Agent::~Agent() {
categories_.clear();
writers_.clear();
StopTracing();
uv_close(reinterpret_cast<uv_handle_t*>(&initialize_writer_async_), nullptr);
uv_run(&tracing_loop_, UV_RUN_ONCE);
CheckedUvLoopClose(&tracing_loop_);