From 0812b244e524eca631f6a12c10fb5d8f035b3f80 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Tue, 10 Sep 2024 15:23:06 -0400 Subject: [PATCH] ref(profiling) use cleanup instead of destructor --- packages/profiling-node/bindings/cpu_profiler.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/profiling-node/bindings/cpu_profiler.cc b/packages/profiling-node/bindings/cpu_profiler.cc index 00996db9e8c9..a3756a92b39c 100644 --- a/packages/profiling-node/bindings/cpu_profiler.cc +++ b/packages/profiling-node/bindings/cpu_profiler.cc @@ -111,15 +111,9 @@ class MeasurementsTicker { size_t listener_count(); - ~MeasurementsTicker() { + void Cleanup() { uv_timer_stop(&timer); - - auto handle = reinterpret_cast(&timer); - - // Calling uv_close on an inactive handle will cause a segfault. - if (uv_is_active(handle)) { - uv_close(handle, nullptr); - } + uv_close(reinterpret_cast(&timer), nullptr); } }; @@ -1155,6 +1149,7 @@ void FreeAddonData(napi_env env, void *data, void *hint) { profiler->cpu_profiler = nullptr; } + profiler->measurements_ticker.Cleanup(); delete profiler; }