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 2018-07-27 18:16:35 +02:00
parent 5e83a2abd0
commit 281e5a3cee
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 7 additions and 1 deletions

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) {

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_);