Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assertChipStackLockedByCurrentThread when accessing statics in src/system/SystemStats.cpp #25485

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/core/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
vivien-apple marked this conversation as resolved.
Show resolved Hide resolved
"${nlunit_test_root}:nlunit-test",
]
}
Expand Down
29 changes: 12 additions & 17 deletions src/platform/Darwin/BleConnectionDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -380,24 +380,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]);
Expand Down
1 change: 1 addition & 0 deletions src/setup_payload/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ chip_test_suite("tests") {

public_deps = [
"${chip_root}/src/lib/support:testing",
"${chip_root}/src/platform",
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
"${chip_root}/src/setup_payload",
"${nlunit_test_root}:nlunit-test",
]
Expand Down
9 changes: 9 additions & 0 deletions src/system/SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <system/SystemStats.h>

#include <lib/support/SafeInt.h>
#include <platform/LockTracker.h>

#include <string.h>

Expand Down Expand Up @@ -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));

Expand Down