Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-apple committed Sep 13, 2021
1 parent 1f3a62a commit ceee4f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(EndpointId endpoin
{
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: RemoveFabric"); // TODO: Generate emberAfFabricClusterPrintln

// We are extracting the current fabric index here, even though it's used after sending the response.
// This is done to prevent accidental update of emberAfCurrentCommand()->source while sending the command's response.
FabricIndex currentFabricIndex = emberAfCurrentCommand()->source->GetSecureSession().GetFabricIndex();

EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
Expand All @@ -283,6 +285,7 @@ bool emberAfOperationalCredentialsClusterRemoveFabricCallback(EndpointId endpoin
// retries to send the message and runs into issues.
// We are hijacking the exchange delegate here (as no more messages should be received on this exchange),
// and wait for it to close, before expiring the secure sessions for the fabric.
// TODO: https://github.com/project-chip/connectedhomeip/issues/9642
ec->SetDelegate(&gFabricCleanupExchangeDelegate);
}
else
Expand Down
14 changes: 5 additions & 9 deletions src/transport/PeerConnections.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,18 @@ class PeerConnections
CHECK_RETURN_VALUE
PeerConnectionState * FindPeerConnectionStateByFabric(FabricIndex fabric)
{
PeerConnectionState * state = nullptr;
PeerConnectionState * iter = &mStates[0];

for (; iter < &mStates[kMaxConnectionCount]; iter++)
for (auto & state : mStates)
{
if (!iter->IsInitialized())
if (!state.IsInitialized())
{
continue;
}
if (iter->GetFabricIndex() == fabric)
if (state.GetFabricIndex() == fabric)
{
state = iter;
break;
return &state;
}
}
return state;
return nullptr;
}

/// Convenience method to mark a peer connection state as active
Expand Down

0 comments on commit ceee4f3

Please sign in to comment.