Skip to content

Commit 00c33a5

Browse files
addaleaxtargos
authored andcommitted
src: clean up agent loop when exiting through destructor
Fixes: #22042 PR-URL: #21867 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]>
1 parent ba480d3 commit 00c33a5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ static struct {
398398
}
399399

400400
void Dispose() {
401+
tracing_agent_.reset(nullptr);
401402
platform_->Shutdown();
402403
delete platform_;
403404
platform_ = nullptr;
404-
tracing_agent_.reset(nullptr);
405405
}
406406

407407
void DrainVMTasks(Isolate* isolate) {

src/tracing/agent.cc

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Agent::Agent() {
5959
Agent* agent = ContainerOf(&Agent::initialize_writer_async_, async);
6060
agent->InitializeWritersOnThread();
6161
}), 0);
62+
uv_unref(reinterpret_cast<uv_handle_t*>(&initialize_writer_async_));
6263
}
6364

6465
void Agent::InitializeWritersOnThread() {
@@ -72,6 +73,11 @@ void Agent::InitializeWritersOnThread() {
7273
}
7374

7475
Agent::~Agent() {
76+
categories_.clear();
77+
writers_.clear();
78+
79+
StopTracing();
80+
7581
uv_close(reinterpret_cast<uv_handle_t*>(&initialize_writer_async_), nullptr);
7682
uv_run(&tracing_loop_, UV_RUN_ONCE);
7783
CheckedUvLoopClose(&tracing_loop_);

0 commit comments

Comments
 (0)