Skip to content

Commit

Permalink
Nil check needed here (#32689)
Browse files Browse the repository at this point in the history
* Nil check needed here

* Restyled by clang-format

* Adding pools here

* Restyled by whitespace

* Restyled by clang-format

* Upping this queue

* Removing autorelease calls

* Restyled by whitespace

* Removing these too

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
woody-apple and restyled-commits authored Mar 23, 2024
1 parent db74b20 commit 437c574
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,11 @@ - (void)_setupSubscription
MTRWeakReference<MTRDevice *> * weakSelf = [MTRWeakReference weakReferenceWithObject:self];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kTimeToWaitBeforeMarkingUnreachableAfterSettingUpSubscription * NSEC_PER_SEC)), self.queue, ^{
MTRDevice * strongSelf = weakSelf.strongObject;
os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf _markDeviceAsUnreachableIfNotSusbcribed];
os_unfair_lock_unlock(&strongSelf->_lock);
if (strongSelf != nil) {
os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf _markDeviceAsUnreachableIfNotSusbcribed];
os_unfair_lock_unlock(&strongSelf->_lock);
}
});

[_deviceController
Expand Down
38 changes: 25 additions & 13 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller

__block id resumptionNodeList;
dispatch_sync(_storageDelegateQueue, ^{
@autoreleasepool {
resumptionNodeList = [_storageDelegate controller:_controller
valueForKey:sResumptionNodeListKey
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
}
resumptionNodeList = [_storageDelegate controller:_controller
valueForKey:sResumptionNodeListKey
securityLevel:MTRStorageSecurityLevelSecure
Expand All @@ -145,6 +151,7 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller
} else {
_nodesWithResumptionInfo = [[NSMutableArray alloc] init];
}

return self;
}

Expand Down Expand Up @@ -233,10 +240,12 @@ - (MTRCertificateTLVBytes _Nullable)fetchLastLocallyUsedNOC
{
__block id data;
dispatch_sync(_storageDelegateQueue, ^{
data = [_storageDelegate controller:_controller
valueForKey:sLastLocallyUsedNOCKey
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
@autoreleasepool {
data = [_storageDelegate controller:_controller
valueForKey:sLastLocallyUsedNOCKey
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
}
});

if (data == nil) {
Expand All @@ -259,10 +268,12 @@ - (nullable MTRCASESessionResumptionInfo *)_findResumptionInfoWithKey:(nullable

__block id resumptionInfo;
dispatch_sync(_storageDelegateQueue, ^{
resumptionInfo = [_storageDelegate controller:_controller
valueForKey:key
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
@autoreleasepool {
resumptionInfo = [_storageDelegate controller:_controller
valueForKey:key
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
}
});

if (resumptionInfo == nil) {
Expand Down Expand Up @@ -304,11 +315,12 @@ - (nullable MTRCASESessionResumptionInfo *)_findResumptionInfoWithKey:(nullable
- (id)_fetchAttributeCacheValueForKey:(NSString *)key expectedClass:(Class)expectedClass;
{
id data;
data = [_storageDelegate controller:_controller
valueForKey:key
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];

@autoreleasepool {
data = [_storageDelegate controller:_controller
valueForKey:key
securityLevel:MTRStorageSecurityLevelSecure
sharingType:MTRStorageSharingTypeNotShared];
}
if (data == nil) {
return nil;
}
Expand Down
5 changes: 4 additions & 1 deletion src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ dispatch_queue_t PlatformManagerImpl::GetWorkQueue()
{
if (mWorkQueue == nullptr)
{
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
mWorkQueue =
dispatch_queue_create(CHIP_CONTROLLER_QUEUE,
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL,
QOS_CLASS_USER_INITIATED, QOS_MIN_RELATIVE_PRIORITY));
dispatch_suspend(mWorkQueue);
dispatch_queue_set_specific(mWorkQueue, &sPlatformManagerKey, this, nullptr);
mIsWorkQueueSuspended = true;
Expand Down

0 comments on commit 437c574

Please sign in to comment.