-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Characteristic notification handler goroutine leak #260
Comments
I saw similar behavior in v0.8.0, along with the memory leak in my issue here #252. I'm no longer seeing the memory leak as mentioned in my issue, but I am seeing a leak in v0.9.0 such as the one you mentioned here when connecting to a device and enabling notifications, along with undesirable events if |
Fixing the |
When notifications are enabled on a
DeviceCharacteristic
on Linux, it starts a new goroutine listening on a channel for DBus signals, but when a device disconnects (or whenEnableNotifications(nil)
is called), thec.property
channel is never closed, so the goroutine will keep waiting for a signal on its property channel.In the case of
EnableNotifications(nil)
, the goroutine will sleep forever and the signal will never come due to the call toRemoveSignal
here:bluetooth/gattc_linux.go
Line 282 in 12b6f0b
However, when a device disconnects,
RemoveSignal
is never called, so when a new notification handler is added to that characteristic after the device reconnects, theMatchSignal
is re-added, so the old goroutine starts receiving signals again and executes its old handler, causing duplicated events and other undesirable issues.The text was updated successfully, but these errors were encountered: