Skip to content

Commit

Permalink
[Darwin] New XPC bits need to initialize properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jtung-apple committed Aug 21, 2024
1 parent 068da61 commit f78da85
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ - (instancetype)initForSubclassesWithNodeID:(NSNumber *)nodeID controller:(MTRDe
if (self = [super init]) {
_lock = OS_UNFAIR_LOCK_INIT;
_delegates = [NSMutableSet set];
_deviceController = controller;
_nodeID = nodeID;
}

return self;
Expand Down
3 changes: 0 additions & 3 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
using namespace chip::Tracing::DarwinFramework;

@implementation MTRDeviceController {
// queue used to serialize all work performed by the MTRDeviceController
dispatch_queue_t _chipWorkQueue;

chip::Controller::DeviceCommissioner * _cppCommissioner;
chip::Credentials::PartialDACVerifier * _partialDACVerifier;
chip::Credentials::DefaultDACVerifier * _defaultDACVerifier;
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readwrite, nullable) NSMapTable * nodeIDToDeviceMap;
@property (readonly, assign) os_unfair_lock_t deviceMapLock;

// queue used to serialize all work performed by the MTRDeviceController
// (moved here so subclasses can initialize differently)
@property (readwrite, retain) dispatch_queue_t chipWorkQueue;

- (instancetype)initForSubclasses;

#pragma mark - MTRDeviceControllerFactory methods
Expand Down
2 changes: 2 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection

self.xpcConnection = connectionBlock();
self.uniqueIdentifier = UUID;
self.chipWorkQueue = dispatch_queue_create("MTRDeviceController_XPC_queue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
self.nodeIDToDeviceMap = [NSMapTable strongToWeakObjectsMapTable];

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

0 comments on commit f78da85

Please sign in to comment.