Skip to content

Commit a836887

Browse files
Fix handling of non-permitted messages in ExchangeContext. (#33148) (#33291)
They should not count as responses, since we don't notify our delegate about them. Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 69faf5f commit a836887

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
@@ -592,21 +592,26 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
592592
// Set kFlagReceivedAtLeastOneMessage to true since we have received at least one new application level message
593593
SetHasReceivedAtLeastOneMessage(true);
594594

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

600-
// If the context was expecting a response to a previously sent message, this message
601-
// is implicitly that response.
602-
SetResponseExpected(false);
603-
}
606+
// If the context was expecting a response to a previously sent message, this message
607+
// is implicitly that response.
608+
SetResponseExpected(false);
609+
}
604610

605-
// Don't send messages on to our delegate if our dispatch does not allow
606-
// those messages.
607-
if (mDelegate != nullptr && mDispatch.MessagePermitted(payloadHeader.GetProtocolID(), payloadHeader.GetMessageType()))
608-
{
609-
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
611+
if (mDelegate != nullptr)
612+
{
613+
return mDelegate->OnMessageReceived(this, payloadHeader, std::move(msgBuf));
614+
}
610615
}
611616

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

0 commit comments

Comments
 (0)