Skip to content

Commit

Permalink
[darwin] Data race when accessing onConnectionComplete (#25487)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Mar 6, 2023
1 parent d5ebdab commit 80a2c6e
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/platform/Darwin/BleConnectionDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,19 @@ - (void)resetTimer
// All our callback dispatch must happen on _chipWorkQueue
- (void)dispatchConnectionError:(CHIP_ERROR)error
{
if (self.onConnectionError == nil) {
return;
}

dispatch_async(_chipWorkQueue, ^{
self.onConnectionError(self.appState, error);
if (self.onConnectionError != nil) {
self.onConnectionError(self.appState, error);
}
});
}

- (void)dispatchConnectionComplete:(CBPeripheral *)peripheral
{
if (self.onConnectionComplete == nil) {
return;
}

dispatch_async(_chipWorkQueue, ^{
self.onConnectionComplete(self.appState, (__bridge void *) peripheral);
if (self.onConnectionComplete != nil) {
self.onConnectionComplete(self.appState, (__bridge void *) peripheral);
}
});
}

Expand Down

0 comments on commit 80a2c6e

Please sign in to comment.