Skip to content

Commit

Permalink
Improve the error message when the BDX transfer pool is exhausted.
Browse files Browse the repository at this point in the history
  • Loading branch information
harimau-qirex committed Sep 11, 2024
1 parent 024a8a9 commit efebf7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/controller/python/chip/bdx/bdx-transfer-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ BdxTransfer * BdxTransferManager::Allocate()
VerifyOrReturnValue(mExpectedTransfers != 0, nullptr);

BdxTransfer * result = mTransferPool.CreateObject(mSystemLayer);
VerifyOrReturnValue(result != nullptr, nullptr);
if (result == nullptr) {
ChipLogError(BDX, "Failed to allocate BDX transfer. The pool (size %d) is exhausted.",
static_cast<int>(kTransferPoolSize));
return nullptr;
}
result->SetDelegate(mBdxTransferDelegate);

--mExpectedTransfers;
Expand Down
6 changes: 5 additions & 1 deletion src/controller/python/chip/bdx/bdx-transfer-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class BdxTransferManager : public BdxTransferPool
void Release(BdxTransfer * bdxTransfer) override;

private:
ObjectPool<BdxTransfer, 2> mTransferPool;
// The maximum number of transfers to support at once. This number was chosen because it should be sufficient for
// current tests that use BDX.
static constexpr size_t kTransferPoolSize = 2;

ObjectPool<BdxTransfer, kTransferPoolSize> mTransferPool;
System::Layer * mSystemLayer = nullptr;
BdxTransfer::Delegate * mBdxTransferDelegate = nullptr;
size_t mExpectedTransfers = 0;
Expand Down

0 comments on commit efebf7f

Please sign in to comment.