diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 295f7a337d09dd..ec83bc715411c1 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -37,6 +37,7 @@ chip_test_suite("tests") { public_deps = [ "${chip_root}/src/lib/core", "${chip_root}/src/lib/support:testing", + "${chip_root}/src/platform", "${nlunit_test_root}:nlunit-test", ] } diff --git a/src/platform/Darwin/BleConnectionDelegateImpl.mm b/src/platform/Darwin/BleConnectionDelegateImpl.mm index 67ab838c4af525..d69623006d84ab 100644 --- a/src/platform/Darwin/BleConnectionDelegateImpl.mm +++ b/src/platform/Darwin/BleConnectionDelegateImpl.mm @@ -376,24 +376,19 @@ - (void)peripheral:(CBPeripheral *)peripheral chip::Ble::ChipBleUUID charId; [BleConnection fillServiceWithCharacteristicUuids:characteristic svcId:&svcId charId:&charId]; - // build a inet buffer from the rxEv and send to blelayer. - __block chip::System::PacketBufferHandle msgBuf - = chip::System::PacketBufferHandle::NewWithData(characteristic.value.bytes, characteristic.value.length); - - if (!msgBuf.IsNull()) { - dispatch_async(_chipWorkQueue, ^{ - if (!_mBleLayer->HandleIndicationReceived((__bridge void *) peripheral, &svcId, &charId, std::move(msgBuf))) { - // since this error comes from device manager core - // we assume it would do the right thing, like closing the connection - ChipLogError(Ble, "Failed at handling incoming BLE data"); - } - }); - } else { - ChipLogError(Ble, "Failed at allocating buffer for incoming BLE data"); - dispatch_async(_chipWorkQueue, ^{ + dispatch_async(_chipWorkQueue, ^{ + // build a inet buffer from the rxEv and send to blelayer. + auto msgBuf = chip::System::PacketBufferHandle::NewWithData(characteristic.value.bytes, characteristic.value.length); + + if (msgBuf.IsNull()) { + ChipLogError(Ble, "Failed at allocating buffer for incoming BLE data"); _mBleLayer->HandleConnectionError((__bridge void *) peripheral, CHIP_ERROR_NO_MEMORY); - }); - } + } else if (!_mBleLayer->HandleIndicationReceived((__bridge void *) peripheral, &svcId, &charId, std::move(msgBuf))) { + // since this error comes from device manager core + // we assume it would do the right thing, like closing the connection + ChipLogError(Ble, "Failed at handling incoming BLE data"); + } + }); } else { ChipLogError( Ble, "BLE:Error receiving indication of Characteristics on the device: [%s]", [error.localizedDescription UTF8String]); diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index 2d76bb4cfa5680..1b39f08f0eca25 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -34,6 +34,7 @@ chip_test_suite("tests") { public_deps = [ "${chip_root}/src/lib/support:testing", + "${chip_root}/src/platform", "${chip_root}/src/setup_payload", "${nlunit_test_root}:nlunit-test", ] diff --git a/src/system/SystemStats.cpp b/src/system/SystemStats.cpp index bf3473fd62c924..244a2517b31c78 100644 --- a/src/system/SystemStats.cpp +++ b/src/system/SystemStats.cpp @@ -29,6 +29,7 @@ #include #include +#include #include @@ -59,21 +60,29 @@ count_t sHighWatermarks[kNumEntries]; const Label * GetStrings() { + assertChipStackLockedByCurrentThread(); + return sStatsStrings; } count_t * GetResourcesInUse() { + assertChipStackLockedByCurrentThread(); + return sResourcesInUse; } count_t * GetHighWatermarks() { + assertChipStackLockedByCurrentThread(); + return sHighWatermarks; } void UpdateSnapshot(Snapshot & aSnapshot) { + assertChipStackLockedByCurrentThread(); + memcpy(&aSnapshot.mResourcesInUse, &sResourcesInUse, sizeof(aSnapshot.mResourcesInUse)); memcpy(&aSnapshot.mHighWatermarks, &sHighWatermarks, sizeof(aSnapshot.mHighWatermarks));