Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Jun 6, 2022
1 parent 51c2006 commit 76f635a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,8 @@ bool InteractionModelEngine::EnsureResourceForSubscription(FabricIndex aFabricIn

bool InteractionModelEngine::TrimFabricForRead(FabricIndex aFabricIndex)
{
const size_t minSupportedPathsPerFabricForRead = GetGuaranteedReadRequestsPerFabric() * kMinSupportedPathsPerReadRequest;
const size_t guaranteedReadRequestsPerFabric = GetGuaranteedReadRequestsPerFabric();
const size_t minSupportedPathsPerFabricForRead = guaranteedReadRequestsPerFabric * kMinSupportedPathsPerReadRequest;

size_t attributePathsUsedByCurrentFabric = 0;
size_t eventPathsUsedByCurrentFabric = 0;
Expand Down Expand Up @@ -841,7 +842,7 @@ bool InteractionModelEngine::TrimFabricForRead(FabricIndex aFabricIndex)
if (candidate != nullptr &&
((attributePathsUsedByCurrentFabric > minSupportedPathsPerFabricForRead ||
eventPathsUsedByCurrentFabric > minSupportedPathsPerFabricForRead ||
readTransactionsOnCurrentFabric > GetGuaranteedReadRequestsPerFabric()) ||
readTransactionsOnCurrentFabric > guaranteedReadRequestsPerFabric) ||
// Always evict the transactions on PASE sessions if the fabric table is full.
(aFabricIndex == kUndefinedFabricIndex && mpFabricTable->FabricCount() == GetConfigMaxFabrics())))
{
Expand Down Expand Up @@ -871,6 +872,8 @@ Protocols::InteractionModel::Status InteractionModelEngine::EnsureResourceForRea
const size_t eventPathCap = allowUnlimited ? SIZE_MAX : GetPathPoolCapacityForReads();
const size_t readHandlerCap = allowUnlimited ? SIZE_MAX : GetReadHandlerPoolCapacityForReads();

const size_t guaranteedReadRequestsPerFabric = GetGuaranteedReadRequestsPerFabric();

size_t usedAttributePaths = 0;
size_t usedEventPaths = 0;
size_t usedReadHandlers = 0;
Expand Down Expand Up @@ -931,10 +934,9 @@ Protocols::InteractionModel::Status InteractionModelEngine::EnsureResourceForRea

// Resources exhausted, since there is already some read requests ongoing on this fabric, please retry later.
if (usedAttributePathsInFabric + aRequestedAttributePathCount >
kMinSupportedPathsPerReadRequest * GetGuaranteedReadRequestsPerFabric() ||
usedEventPathsInFabric + aRequestedEventPathCount >
kMinSupportedPathsPerReadRequest * GetGuaranteedReadRequestsPerFabric() ||
usedReadHandlersInFabric >= GetGuaranteedReadRequestsPerFabric())
kMinSupportedPathsPerReadRequest * guaranteedReadRequestsPerFabric ||
usedEventPathsInFabric + aRequestedEventPathCount > kMinSupportedPathsPerReadRequest * guaranteedReadRequestsPerFabric ||
usedReadHandlersInFabric >= guaranteedReadRequestsPerFabric)
{
return Protocols::InteractionModel::Status::Busy;
}
Expand Down Expand Up @@ -983,7 +985,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::EnsureResourceForRea
{
return Protocols::InteractionModel::Status::Busy;
}
else if (usedReadHandlers >= readHandlerCap)
if (usedReadHandlers >= readHandlerCap)
{
return Protocols::InteractionModel::Status::Busy;
}
Expand Down

0 comments on commit 76f635a

Please sign in to comment.