-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improve ExchangeMessageDispatch #17521
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,6 +288,12 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const | |
} | ||
} | ||
|
||
if (GetDispatchForDelegate(delegate).IsEncryptionRequired() != session->IsEncrypted()) | ||
{ | ||
ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not the error type we used to have here. Why is this the right type? Also, this check will always fail if |
||
return; | ||
} | ||
|
||
// If rcvd msg is from initiator then this exchange is created as not Initiator. | ||
// If rcvd msg is not from initiator then this exchange is created as Initiator. | ||
// Note that if matchingUMH is not null then rcvd msg if from initiator. | ||
|
@@ -310,13 +316,6 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const | |
ChipLogDetail(ExchangeManager, "Handling via exchange: " ChipLogFormatExchange ", Delegate: %p", ChipLogValueExchange(ec), | ||
ec->GetDelegate()); | ||
|
||
if (ec->IsEncryptionRequired() != packetHeader.IsEncrypted()) | ||
{ | ||
ChipLogError(ExchangeManager, "OnMessageReceived failed, err = %s", ErrorStr(CHIP_ERROR_INVALID_MESSAGE_TYPE)); | ||
ec->Close(); | ||
return; | ||
} | ||
|
||
CHIP_ERROR err = ec->HandleMessage(packetHeader.GetMessageCounter(), payloadHeader, source, msgFlags, std::move(msgBuf)); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes an already-large method much larger and quite hard to read/understand, what with the various "return" bits that return out of the lambda, not the overall method. What is the benefit of inlining this instead of having it as a separate function (possibly on ExchangeContext if we don't think it should be on the message dispatch)?