Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of non-permitted messages in ExchangeContext. #33148

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,21 +596,26 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
// Set kFlagReceivedAtLeastOneMessage to true since we have received at least one new application level message
SetHasReceivedAtLeastOneMessage(true);

if (IsResponseExpected())
// Don't send messages on to our delegate if our dispatch does not allow
// those messages. Those messages should also not be treated as responses,
// since if our delegate is expecting a response we will not notify it about
// these messages.
if (mDispatch.MessagePermitted(payloadHeader.GetProtocolID(), payloadHeader.GetMessageType()))
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
{
// Since we got the response, cancel the response timer.
CancelResponseTimer();
if (IsResponseExpected())
{
// Since we got the response, cancel the response timer.
CancelResponseTimer();

// If the context was expecting a response to a previously sent message, this message
// is implicitly that response.
SetResponseExpected(false);
}
// If the context was expecting a response to a previously sent message, this message
// is implicitly that response.
SetResponseExpected(false);
}

// Don't send messages on to our delegate if our dispatch does not allow
// those messages.
if (mDelegate != nullptr && mDispatch.MessagePermitted(payloadHeader.GetProtocolID(), payloadHeader.GetMessageType()))
{
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
if (mDelegate != nullptr)
{
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
}
}

DefaultOnMessageReceived(this, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), messageCounter,
Expand Down
Loading