Skip to content

Commit ee4fe0a

Browse files
Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 3f0eeed commit ee4fe0a

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

src/app/InteractionModelEngine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ bool InteractionModelEngine::SubjectHasPersistedSubscription(FabricIndex aFabric
364364

365365
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
366366
auto * iterator = mpSubscriptionResumptionStorage->IterateSubscriptions();
367-
// Verify that we were able t0 allocate an iterator. If not, assume we have a persisted subscription.
367+
// Verify that we were able to allocate an iterator. If not, assume we have a persisted subscription.
368368
VerifyOrReturnValue(iterator, true);
369369

370370
SubscriptionResumptionStorage::SubscriptionInfo subscriptionInfo;

src/app/InteractionModelEngine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
678678
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST
679679

680680
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
681-
int8_t mNumOfSubscriptionToResume = 0;
681+
int8_t mNumOfSubscriptionsToResume = 0;
682682
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
683683
bool HasSubscriptionsToResume();
684684
uint32_t ComputeTimeSecondsTillNextSubscriptionResumption();

src/app/icd/server/ICDManager.cpp

+13-15
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ bool ICDManager::CheckInMessagesWouldBeSent(const std::function<ShouldCheckInMsg
257257
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
258258
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
259259
/**
260-
* @brief Implementation for when the persistant subscription and subscription timeout resumption feature are present.
261-
* Function checks that there no active or persisted subscriptions for a given fabricIndex or subjectID.
260+
* @brief Implementation for when the persistent subscription and subscription timeout resumption feature are present.
261+
* Function checks that there are no active or persisted subscriptions for a given fabricIndex or subjectID.
262262
*
263263
* @param aFabricIndex
264264
* @param subjectID subjectID to check. Can be an operational node id or a CAT
@@ -273,8 +273,8 @@ bool ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction(FabricIndex aFabric
273273
}
274274
#else
275275
/**
276-
* @brief Implementation for when the persistant subscription feature is present without the subscription timeout resumption
277-
* feature. Function checks that there no active subscriptions. If the boot up subscription resumption has not been completed,
276+
* @brief Implementation for when the persistent subscription feature is present without the subscription timeout resumption
277+
* feature. Function checks that there are no active subscriptions. If the boot up subscription resumption has not been completed,
278278
* function also checks if there are persisted subscriptions.
279279
*
280280
* @note The persistent subscriptions feature tries to resume subscriptions at the highest min interval
@@ -286,26 +286,24 @@ bool ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction(FabricIndex aFabric
286286
* @param subjectID subjectID to check. Can be an opperationnal node id or a CAT
287287
*
288288
* @return true Returns true if the fabricIndex and subjectId combination does not have an active subscription.
289-
* If the boot up susbscription has not been completed, there must not be a persisted subscription either.
289+
* If the boot up subscription resumption has not been completed, there must not be a persisted subscription either.
290290
* @return false Returns false if the fabricIndex and subjectId combination has an active subscription.
291-
* If the boot up susbscription has not been completed,
291+
* If the boot up subscription resumption has not been completed,
292292
* returns false if the fabricIndex and subjectId combination has a persisted subscription.
293293
*/
294294
bool ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction(FabricIndex aFabricIndex, NodeId subjectID)
295295
{
296-
bool wouldSendCheckIn = !(mSubInfoProvider->SubjectHasActiveSubscription(aFabricIndex, subjectID));
297-
298-
if (!mIsBootUpResumeSubscriptionExecuted)
299-
{
300-
wouldSendCheckIn = wouldSendCheckIn && !mSubInfoProvider->SubjectHasPersistedSubscription(aFabricIndex, subjectID);
296+
bool mightHaveSubscription = mSubInfoProvider->SubjectHasActiveSubscription(aFabricIndex, subjectID);
297+
if (!mightHaveSubscription && !mIsBootUpResumeSubscriptionExecuted) {
298+
mightHaveSubscription = mSubInfoProvider->SubjectHasPersistedSubscription(aFabricIndex, subjectID);
301299
}
302-
303-
return wouldSendCheckIn;
300+
301+
return !mightHaveSubscription;
304302
}
305303
#endif // CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
306304
#else
307305
/**
308-
* @brief Implementation for when neither the persistant subscription and subscription timeout resumption features are present.
306+
* @brief Implementation for when neither the persistent subscription nor the subscription timeout resumption features are present.
309307
* Function checks that there no active sbuscriptions for a given fabricIndex and subjectId combination.
310308
*
311309
* @param aFabricIndex
@@ -391,7 +389,7 @@ void ICDManager::UpdateOperationState(OperationalState state)
391389
mOperationalState = OperationalState::IdleMode;
392390

393391
#if CHIP_CONFIG_ENABLE_ICD_CIP
394-
std::function<ShouldCheckInMsgsBeSentFunction> function =
392+
std::function<ShouldCheckInMsgsBeSentFunction> sendCheckInMessagesOnActiveMode =
395393
std::bind(&ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction, this, std::placeholders::_1, std::placeholders::_2);
396394
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
397395

src/app/server/Server.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
333333
SuccessOrExit(err);
334334

335335
#if CHIP_CONFIG_ENABLE_ICD_SERVER
336-
chip::app::InteractionModelEngine::GetInstance()->SetICDManager(&mICDManager);
336+
app::InteractionModelEngine::GetInstance()->SetICDManager(&mICDManager);
337337
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
338338

339339
// ICD Init needs to be after data model init and InteractionModel Init
@@ -449,7 +449,7 @@ void Server::OnPlatformEvent(const DeviceLayer::ChipDeviceEvent & event)
449449
// We trigger Check-In messages before resuming subscriptions to avoid doing both.
450450
if (!mFailSafeContext.IsFailSafeArmed())
451451
{
452-
std::function<chip::app::ICDManager::ShouldCheckInMsgsBeSentFunction> function =
452+
std::function<app::ICDManager::ShouldCheckInMsgsBeSentFunction> function =
453453
std::bind(&Server::ShouldCheckInMsgsBeSentAtBootFunction, this, std::placeholders::_1, std::placeholders::_2);
454454
mICDManager.TriggerCheckInMessages(function);
455455
}
@@ -530,11 +530,10 @@ bool Server::ShouldCheckInMsgsBeSentAtBootFunction(FabricIndex aFabricIndex, Nod
530530
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
531531
// If at least one registration has a persisted entry, do not send Check-In message.
532532
// The resumption of the persisted subscription will serve the same function a check-in would have served.
533-
VerifyOrReturnValue(!app::InteractionModelEngine::GetInstance()->SubjectHasPersistedSubscription(aFabricIndex, subjectID),
534-
false);
535-
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
536-
533+
return !app::InteractionModelEngine::GetInstance()->SubjectHasPersistedSubscription(aFabricIndex, subjectID);
534+
#else
537535
return true;
536+
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
538537
}
539538
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
540539

@@ -581,7 +580,7 @@ void Server::Shutdown()
581580
chip::Dnssd::Resolver::Instance().Shutdown();
582581
chip::app::InteractionModelEngine::GetInstance()->Shutdown();
583582
#if CHIP_CONFIG_ENABLE_ICD_SERVER
584-
chip::app::InteractionModelEngine::GetInstance()->SetICDManager(nullptr);
583+
app::InteractionModelEngine::GetInstance()->SetICDManager(nullptr);
585584
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
586585
mCommissioningWindowManager.Shutdown();
587586
mMessageCounterManager.Shutdown();

0 commit comments

Comments
 (0)