Skip to content

Commit ff6863e

Browse files
authored
[Darwin] New XPC bits need to initialize properly (project-chip#35110)
1 parent 927c818 commit ff6863e

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+2
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ - (instancetype)initForSubclassesWithNodeID:(NSNumber *)nodeID controller:(MTRDe
491491
if (self = [super init]) {
492492
_lock = OS_UNFAIR_LOCK_INIT;
493493
_delegates = [NSMutableSet set];
494+
_deviceController = controller;
495+
_nodeID = nodeID;
494496
}
495497

496498
return self;

src/darwin/Framework/CHIP/MTRDeviceController.mm

-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@
109109
using namespace chip::Tracing::DarwinFramework;
110110

111111
@implementation MTRDeviceController {
112-
// queue used to serialize all work performed by the MTRDeviceController
113-
dispatch_queue_t _chipWorkQueue;
114-
115112
chip::Controller::DeviceCommissioner * _cppCommissioner;
116113
chip::Credentials::PartialDACVerifier * _partialDACVerifier;
117114
chip::Credentials::DefaultDACVerifier * _defaultDACVerifier;

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ NS_ASSUME_NONNULL_BEGIN
6868
@property (nonatomic, readwrite, nullable) NSMapTable * nodeIDToDeviceMap;
6969
@property (readonly, assign) os_unfair_lock_t deviceMapLock;
7070

71+
// queue used to serialize all work performed by the MTRDeviceController
72+
// (moved here so subclasses can initialize differently)
73+
@property (readwrite, retain) dispatch_queue_t chipWorkQueue;
74+
7175
- (instancetype)initForSubclasses;
7276

7377
#pragma mark - MTRDeviceControllerFactory methods

src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection
7979

8080
self.xpcConnection = connectionBlock();
8181
self.uniqueIdentifier = UUID;
82+
self.chipWorkQueue = dispatch_queue_create("MTRDeviceController_XPC_queue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
83+
self.nodeIDToDeviceMap = [NSMapTable strongToWeakObjectsMapTable];
8284

8385
MTR_LOG("Set up XPC Connection: %@", self.xpcConnection);
8486
if (self.xpcConnection) {

0 commit comments

Comments
 (0)