Skip to content

Commit 3c808ab

Browse files
Fix handling of non-permitted messages in ExchangeContext. (#33148) (#33292)
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 798deb7 commit 3c808ab

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
@@ -595,21 +595,26 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
595595
return CHIP_ERROR_INCORRECT_STATE;
596596
}
597597

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

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

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

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

0 commit comments

Comments
 (0)