Skip to content

Commit

Permalink
src: clean up agent loop when exiting through destructor
Browse files Browse the repository at this point in the history
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 Aug 1, 2018
1 parent ba480d3 commit 00c33a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/tracing/agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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_);
Expand Down

0 comments on commit 00c33a5

Please sign in to comment.