Skip to content

Commit

Permalink
The ExchangeContext is not closed once a message has been dispatched …
Browse files Browse the repository at this point in the history
…via CHIPDeviceController to a CHIPDevice (#6045)
  • Loading branch information
vivien-apple authored Apr 15, 2021
1 parent 467dd44 commit 3120ae8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,20 @@ CHIP_ERROR DeviceController::ServiceEventSignal()
void DeviceController::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader,
const PayloadHeader & payloadHeader, System::PacketBufferHandle msgBuf)
{
VerifyOrReturn(mState == State::Initialized, ChipLogError(Controller, "OnMessageReceived was called in incorrect state"));
uint16_t index;

VerifyOrReturn(packetHeader.GetSourceNodeId().HasValue(),
ChipLogError(Controller, "OnMessageReceived was called for unknown source node"));
VerifyOrExit(mState == State::Initialized, ChipLogError(Controller, "OnMessageReceived was called in incorrect state"));

uint16_t index = FindDeviceIndex(packetHeader.GetSourceNodeId().Value());
VerifyOrReturn(index < kNumMaxActiveDevices,
ChipLogError(Controller, "OnMessageReceived was called for unknown device object"));
VerifyOrExit(packetHeader.GetSourceNodeId().HasValue(),
ChipLogError(Controller, "OnMessageReceived was called for unknown source node"));

index = FindDeviceIndex(packetHeader.GetSourceNodeId().Value());
VerifyOrExit(index < kNumMaxActiveDevices, ChipLogError(Controller, "OnMessageReceived was called for unknown device object"));

mActiveDevices[index].OnMessageReceived(packetHeader, payloadHeader, std::move(msgBuf));

exit:
ec->Close();
}

void DeviceController::OnResponseTimeout(Messaging::ExchangeContext * ec)
Expand Down

0 comments on commit 3120ae8

Please sign in to comment.