Skip to content

Commit 8b1fd13

Browse files
Fix handling of non-permitted messages in ExchangeContext. (project-chip#33148)
They should not count as responses, since we don't notify our delegate about them.
1 parent b99f6c6 commit 8b1fd13

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/messaging/ExchangeContext.cpp

+17-12
Original file line numberDiff line numberDiff line change
@@ -596,21 +596,26 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
596596
// Set kFlagReceivedAtLeastOneMessage to true since we have received at least one new application level message
597597
SetHasReceivedAtLeastOneMessage(true);
598598

599-
if (IsResponseExpected())
599+
// Don't send messages on to our delegate if our dispatch does not allow
600+
// those messages. Those messages should also not be treated as responses,
601+
// since if our delegate is expecting a response we will not notify it about
602+
// these messages.
603+
if (mDispatch.MessagePermitted(payloadHeader.GetProtocolID(), payloadHeader.GetMessageType()))
600604
{
601-
// Since we got the response, cancel the response timer.
602-
CancelResponseTimer();
605+
if (IsResponseExpected())
606+
{
607+
// Since we got the response, cancel the response timer.
608+
CancelResponseTimer();
603609

604-
// If the context was expecting a response to a previously sent message, this message
605-
// is implicitly that response.
606-
SetResponseExpected(false);
607-
}
610+
// If the context was expecting a response to a previously sent message, this message
611+
// is implicitly that response.
612+
SetResponseExpected(false);
613+
}
608614

609-
// Don't send messages on to our delegate if our dispatch does not allow
610-
// those messages.
611-
if (mDelegate != nullptr && mDispatch.MessagePermitted(payloadHeader.GetProtocolID(), payloadHeader.GetMessageType()))
612-
{
613-
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
615+
if (mDelegate != nullptr)
616+
{
617+
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
618+
}
614619
}
615620

616621
DefaultOnMessageReceived(this, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), messageCounter,

0 commit comments

Comments
 (0)