Skip to content

Commit 437c574

Browse files
Nil check needed here (project-chip#32689)
* 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 <commits@restyled.io>
1 parent db74b20 commit 437c574

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+5-3
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,11 @@ - (void)_setupSubscription
10351035
MTRWeakReference<MTRDevice *> * weakSelf = [MTRWeakReference weakReferenceWithObject:self];
10361036
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (kTimeToWaitBeforeMarkingUnreachableAfterSettingUpSubscription * NSEC_PER_SEC)), self.queue, ^{
10371037
MTRDevice * strongSelf = weakSelf.strongObject;
1038-
os_unfair_lock_lock(&strongSelf->_lock);
1039-
[strongSelf _markDeviceAsUnreachableIfNotSusbcribed];
1040-
os_unfair_lock_unlock(&strongSelf->_lock);
1038+
if (strongSelf != nil) {
1039+
os_unfair_lock_lock(&strongSelf->_lock);
1040+
[strongSelf _markDeviceAsUnreachableIfNotSusbcribed];
1041+
os_unfair_lock_unlock(&strongSelf->_lock);
1042+
}
10411043
});
10421044

10431045
[_deviceController

src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm

+25-13
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller
125125

126126
__block id resumptionNodeList;
127127
dispatch_sync(_storageDelegateQueue, ^{
128+
@autoreleasepool {
129+
resumptionNodeList = [_storageDelegate controller:_controller
130+
valueForKey:sResumptionNodeListKey
131+
securityLevel:MTRStorageSecurityLevelSecure
132+
sharingType:MTRStorageSharingTypeNotShared];
133+
}
128134
resumptionNodeList = [_storageDelegate controller:_controller
129135
valueForKey:sResumptionNodeListKey
130136
securityLevel:MTRStorageSecurityLevelSecure
@@ -145,6 +151,7 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller
145151
} else {
146152
_nodesWithResumptionInfo = [[NSMutableArray alloc] init];
147153
}
154+
148155
return self;
149156
}
150157

@@ -233,10 +240,12 @@ - (MTRCertificateTLVBytes _Nullable)fetchLastLocallyUsedNOC
233240
{
234241
__block id data;
235242
dispatch_sync(_storageDelegateQueue, ^{
236-
data = [_storageDelegate controller:_controller
237-
valueForKey:sLastLocallyUsedNOCKey
238-
securityLevel:MTRStorageSecurityLevelSecure
239-
sharingType:MTRStorageSharingTypeNotShared];
243+
@autoreleasepool {
244+
data = [_storageDelegate controller:_controller
245+
valueForKey:sLastLocallyUsedNOCKey
246+
securityLevel:MTRStorageSecurityLevelSecure
247+
sharingType:MTRStorageSharingTypeNotShared];
248+
}
240249
});
241250

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

260269
__block id resumptionInfo;
261270
dispatch_sync(_storageDelegateQueue, ^{
262-
resumptionInfo = [_storageDelegate controller:_controller
263-
valueForKey:key
264-
securityLevel:MTRStorageSecurityLevelSecure
265-
sharingType:MTRStorageSharingTypeNotShared];
271+
@autoreleasepool {
272+
resumptionInfo = [_storageDelegate controller:_controller
273+
valueForKey:key
274+
securityLevel:MTRStorageSecurityLevelSecure
275+
sharingType:MTRStorageSharingTypeNotShared];
276+
}
266277
});
267278

268279
if (resumptionInfo == nil) {
@@ -304,11 +315,12 @@ - (nullable MTRCASESessionResumptionInfo *)_findResumptionInfoWithKey:(nullable
304315
- (id)_fetchAttributeCacheValueForKey:(NSString *)key expectedClass:(Class)expectedClass;
305316
{
306317
id data;
307-
data = [_storageDelegate controller:_controller
308-
valueForKey:key
309-
securityLevel:MTRStorageSecurityLevelSecure
310-
sharingType:MTRStorageSharingTypeNotShared];
311-
318+
@autoreleasepool {
319+
data = [_storageDelegate controller:_controller
320+
valueForKey:key
321+
securityLevel:MTRStorageSecurityLevelSecure
322+
sharingType:MTRStorageSharingTypeNotShared];
323+
}
312324
if (data == nil) {
313325
return nil;
314326
}

src/platform/Darwin/PlatformManagerImpl.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ dispatch_queue_t PlatformManagerImpl::GetWorkQueue()
169169
{
170170
if (mWorkQueue == nullptr)
171171
{
172-
mWorkQueue = dispatch_queue_create(CHIP_CONTROLLER_QUEUE, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
172+
mWorkQueue =
173+
dispatch_queue_create(CHIP_CONTROLLER_QUEUE,
174+
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL,
175+
QOS_CLASS_USER_INITIATED, QOS_MIN_RELATIVE_PRIORITY));
173176
dispatch_suspend(mWorkQueue);
174177
dispatch_queue_set_specific(mWorkQueue, &sPlatformManagerKey, this, nullptr);
175178
mIsWorkQueueSuspended = true;

0 commit comments

Comments
 (0)