bluetooth icon indicating copy to clipboard operation
bluetooth copied to clipboard

adapter.StopScan() not thread-safe

Open okvorb opened this issue 1 year ago • 2 comments

According to examples StopScan() must be called from Scan() callback but it is not always convinient way to stop a scanner. It will be nice to have an option to call StopScan() method from another goroutine thread safely. Current implementation leads to data race warning on MacOS (but not on Ubuntu/Linux) on next line inside StopScan() method :

if a.scanChan == nil {

a.scanChan variable is not synchronized for reading and writing from different goroutines what leads to the data race.

okvorb avatar Nov 11 '22 14:11 okvorb

Do you plan any activity regarding this issue?

alexander-eroma avatar Feb 02 '24 10:02 alexander-eroma

@okvorb @alexander-eroma would any of you like to make a PR to fix this issue? (I'm not using macOS that often).

aykevl avatar Feb 17 '24 14:02 aykevl