You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that ch is unbuffered. This means when fn is executed, the caller will block until a reader is ready; the only reader is the call to Dial in the above snippet. Therefore if Scan ends up blocking while fn tries to write to the channel, we have a deadlock.
Sure enough, in the Darwin Scan implementation, we have the following code:
// Begin processing responses from ch (events received by DidDiscoverPeripheral).gofunc() {
forr:=rangech {
h(r)
wg.Done()
}
}()
The handler h in this snippet is either fn or a wrapper around fn, depending on whether or not the call to Connect includes a filter. Therefore h blocks until the call to Dial, and the call to wg.Done() never executes. Since the waitgroup never unblocks, Scan never finishes and Dial is never called.
The text was updated successfully, but these errors were encountered:
Current Connect implementation deadlocks on Darwin (https://github.com/go-ble/ble/blob/master/gatt.go#L126-L149):
Note that
ch
is unbuffered. This means whenfn
is executed, the caller will block until a reader is ready; the only reader is the call toDial
in the above snippet. Therefore ifScan
ends up blocking whilefn
tries to write to the channel, we have a deadlock.Sure enough, in the Darwin
Scan
implementation, we have the following code:The handler
h
in this snippet is eitherfn
or a wrapper aroundfn
, depending on whether or not the call to Connect includes a filter. Thereforeh
blocks until the call to Dial, and the call towg.Done()
never executes. Since the waitgroup never unblocks,Scan
never finishes andDial
is never called.The text was updated successfully, but these errors were encountered: