From 56bd361d67e0f375537706e4b2345da54113bedb Mon Sep 17 00:00:00 2001 From: Dave Nicolson Date: Thu, 19 Feb 2026 14:50:25 +0100 Subject: [PATCH] fix: thread cleanup in destructor and Stop method Ensure polling thread is properly stopped and joined before cleanup. Co-authored-by: Claude --- src/BluetoothHciSocket.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BluetoothHciSocket.cpp b/src/BluetoothHciSocket.cpp index bc4ed6f..1c0e69e 100644 --- a/src/BluetoothHciSocket.cpp +++ b/src/BluetoothHciSocket.cpp @@ -583,6 +583,11 @@ void BluetoothHciSocket::SetFilter(const Napi::CallbackInfo& info) { } void BluetoothHciSocket::Start(const Napi::CallbackInfo& info) { + if (!stopFlag && pollingThread.joinable()) { + stopFlag = true; + pollingThread.join(); + } + if (!this->EnsureSocket(info)) { return; }