★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/00c33a5131Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files

src: clean up agent loop when exiting through destructor

Fixes: #22042

PR-URL: #21867
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
  • Loading branch information...
addaleax authored and targos committed Jul 27, 2018
1 parent ba480d3 commit 00c33a5131577901f2155e5690dd1a6c3c798315
Showing with 7 additions and 1 deletion.
  1. +1 −1 src/node.cc
  2. +6 −0 src/tracing/agent.cc
@@ -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) {
@@ -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_);

0 comments on commit 00c33a5

Please sign in to comment.
You can’t perform that action at this time.