-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Darwin] MTRDevice should trigger resubscription on connectivity changes #33016
[Darwin] MTRDevice should trigger resubscription on connectivity changes #33016
Conversation
PR #33016: Size comparison from bfdb5da to 27c30ff Decreases (1 build for efr32)
Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
|
PR #33016: Size comparison from bfdb5da to de68882 Increases above 0.2%:
Increases (70 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
Decreases (11 builds for bl602, bl702, linux, psoc6)
Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
|
de68882
to
f984e7c
Compare
PR #33016: Size comparison from 8a4dffc to f984e7c Decreases (2 builds for efr32)
Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
|
@@ -894,6 +901,9 @@ - (void)_handleResubscriptionNeeded | |||
// former case we recently had a subscription and do not want to be forcing | |||
// retries immediately. | |||
_lastSubscriptionFailureTime = [NSDate now]; | |||
|
|||
// Set up connectivity monitoring in case network routability changes for the positive, to accellerate resubscription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"accelerate".
@nivi-apple had commented about this too; it was resolved but not changed?
self->_connectivityMonitor = [[MTRDeviceConnectivityMonitor alloc] initWithCompressedFabricID:compressedFabricID nodeID:self.nodeID]; | ||
[self->_connectivityMonitor startMonitoringWithHandler:^{ | ||
[self->_deviceController asyncDispatchToMatterQueue:^{ | ||
[self _triggerResubscribeWithReason:"read-through skipped while not subscribed" nodeLikelyReachable:YES]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That ... does not look like the right reason.
@@ -0,0 +1,43 @@ | |||
/** | |||
* Copyright (c) 2023 Project CHIP Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Again, this was resolved but not changed? I am guessing someone applied suggestions and then (a different? same?) someone force-pushed and overwrote this.
Which means: please go through all prior comments on this PR from @nivi-apple and @ksperling-apple and so on and make sure they get addressed.
@@ -0,0 +1,257 @@ | |||
/** | |||
* Copyright (c) 2023 Project CHIP Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
- (instancetype)initWithCompressedFabricID:(NSNumber *)compressedFabricID nodeID:(NSNumber *)nodeID | ||
{ | ||
char instanceName[chip::Dnssd::kMaxOperationalServiceNameSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected the size here to be chip::Dnssd::Operational::kInstanceNameMaxLength + 1
. Why is it not that?
chip::PeerId peerId(static_cast<chip::CompressedFabricId>(compressedFabricID.unsignedLongLongValue), static_cast<chip::NodeId>(nodeID.unsignedLongLongValue)); | ||
CHIP_ERROR err = chip::Dnssd::MakeInstanceName(instanceName, sizeof(instanceName), peerId); | ||
if (err != CHIP_NO_ERROR) { | ||
MTR_LOG_ERROR("%@ could not make instance name", self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be logging the offending PeerId or something, no?
|
||
// Create a nw_connection to monitor connectivity if the host name is not being monitored yet | ||
NSString * hostNameString = [NSString stringWithUTF8String:hostName]; | ||
if (!_connections[hostNameString]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth documenting why we are just using the hostname as the key, when the thing we are monitoring is a (host, port) pair. It's not very obvious.
@@ -256,6 +256,8 @@ NS_ASSUME_NONNULL_BEGIN | |||
- (MTRDevice *)deviceForNodeID:(NSNumber *)nodeID; | |||
- (void)removeDevice:(MTRDevice *)device; | |||
|
|||
- (NSNumber * _Nullable)syncGetCompressedFabricID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followup: Just cache this when controller starts, and nix the sync dispatch and the workarounds we had to make for it in this code.
char testInstanceName[] = "testinstance-name"; | ||
char testHostName[] = "localhost"; | ||
uint16_t testPort = htons(15000); | ||
DNSServiceErrorType dnsError = DNSServiceRegister(&testAdvertiser, flags, 0, testInstanceName, kOperationalType, kLocalDot, testHostName, testPort, 0, NULL, test001_MonitorTest_RegisterCallback, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how does the use of kLocalDot here interact with the changes @nivi-apple made to also do resolves on the SRP domain?
This change is to add a method to monitor network path/viability changes during the subscription / resubscription process, so that in the event network routes to the resolved host name become available / viable, the exponential backoff is reset, and a retry is triggered immediately if appropriate.