Skip to content

Commit

Permalink
Add purge all fabric API
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Jun 9, 2022
1 parent bc4a550 commit 64e6149
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ void ExchangeManager::CloseAllContextsForDelegate(const ExchangeDelegate * deleg
});
}

void ExchangeManager::AbortExchangeForFabricExceptOne(FabricIndex fabricIndex, ExchangeContext * exception)
{
mContextPool.ForEachActiveObject([&](auto * ec) {
if (ec->HasSessionHandle() && ec->GetSessionHandle()->GetPeer().GetFabricIndex() == fabricIndex)
{
if (ec == exception)
ec->SetAutoReleaseSession();
else
ec->Abort();
}
return Loop::Continue;
});
}

void ExchangeManager::AbortExchangeForNodeExceptOne(const ScopedNodeId & node, ExchangeContext * exception)
{
mContextPool.ForEachActiveObject([&](auto * ec) {
Expand Down
5 changes: 3 additions & 2 deletions src/messaging/ExchangeMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ class DLL_EXPORT ExchangeManager : public SessionMessageDelegate
*/
void CloseAllContextsForDelegate(const ExchangeDelegate * delegate);

// This API is used by UpdateNOC command, to invalid all exchanges except the given one.
void AbortExchangeForNodeExceptOne(const ScopedNodeId & node, ExchangeContext * stay);
// This 2 APIs are used by UpdateNOC command, to invalid all exchanges except the given one.
void AbortExchangeForFabricExceptOne(FabricIndex fabricIndex, ExchangeContext * exception);
void AbortExchangeForNodeExceptOne(const ScopedNodeId & node, ExchangeContext * exception);

SessionManager * GetSessionManager() const { return mSessionManager; }

Expand Down
14 changes: 14 additions & 0 deletions src/transport/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ void SessionManager::ExpireAllPASEPairings()
});
}

void SessionManager::ReleaseSessionForFabricExceptOne(FabricIndex fabricIndex, const SessionHandle & exception)
{
mSecureSessions.ForEachSession([&](auto session) {
if (session->GetPeer().GetFabricIndex() == fabricIndex)
{
if (session == exception->AsSecureSession())
session->MarkForInactive();
else
session->MarkForRemoval();
}
return Loop::Continue;
});
}

void SessionManager::ReleaseSessionForNodeExceptOne(const ScopedNodeId & node, const SessionHandle & exception)
{
mSecureSessions.ForEachSession([&](auto session) {
Expand Down
3 changes: 2 additions & 1 deletion src/transport/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class DLL_EXPORT SessionManager : public TransportMgrDelegate
void ExpireAllPASEPairings();

// This API is used by UpdateNOC command, to invalid all sessions except the given one.
void ReleaseSessionForNodeExceptOne(const ScopedNodeId & node, const SessionHandle & stay);
void ReleaseSessionForFabricExceptOne(FabricIndex fabricIndex, const SessionHandle & exception);
void ReleaseSessionForNodeExceptOne(const ScopedNodeId & node, const SessionHandle & exception);

/**
* @brief
Expand Down

0 comments on commit 64e6149

Please sign in to comment.