Skip to content

Commit 0812b24

Browse files
committed
ref(profiling) use cleanup instead of destructor
1 parent d4a2fcd commit 0812b24

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

packages/profiling-node/bindings/cpu_profiler.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,9 @@ class MeasurementsTicker {
111111

112112
size_t listener_count();
113113

114-
~MeasurementsTicker() {
114+
void Cleanup() {
115115
uv_timer_stop(&timer);
116-
117-
auto handle = reinterpret_cast<uv_handle_t *>(&timer);
118-
119-
// Calling uv_close on an inactive handle will cause a segfault.
120-
if (uv_is_active(handle)) {
121-
uv_close(handle, nullptr);
122-
}
116+
uv_close(reinterpret_cast<uv_handle_t *>(&timer), nullptr);
123117
}
124118
};
125119

@@ -1155,6 +1149,7 @@ void FreeAddonData(napi_env env, void *data, void *hint) {
11551149
profiler->cpu_profiler = nullptr;
11561150
}
11571151

1152+
profiler->measurements_ticker.Cleanup();
11581153
delete profiler;
11591154
}
11601155

0 commit comments

Comments
 (0)