NordicSemiconductor / IOS-CoreBluetooth-Mock

Mocking library for CoreBluetooth framework.
BSD 3-Clause "New" or "Revised" License
226 stars 51 forks source link

Deadlock #11

Closed DrAma999 closed 4 years ago

DrAma999 commented 4 years ago

I've found a potential deadlock while trying to simulate a write without response. If I create a CBCentralManager mock that uses the main queue, the code will crash trying to dispatch synchronously on main. CBMCentralManagerMock.swift about line 1105 method

public func writeValue(_ data: Data,
                           for characteristic: CBMCharacteristic,
                           type: CBMCharacteristicWriteType)

Here

else {
            queue.sync { //<--Here
                guard availableWriteWithoutResponseBuffer > 0 else {
                    return
                }
                availableWriteWithoutResponseBuffer -= 1
                _canSendWriteWithoutResponse = false
            }
philips77 commented 4 years ago

Could you prepare a PR with a fix, please?

DrAma999 commented 4 years ago

Sure, I'll do in the weekend

philips77 commented 4 years ago

Closed by #12.