Skip to content

Commit

Permalink
[app] Forget exchange context when SubscribeResponse is received
Browse files Browse the repository at this point in the history
SubscribeResponse is the last action in the Subscribe
transaction and ExchangeContext::HandleMessage
automatically closes exchanges that have no pending
requests nor responses.

ReadClient still kept the pointer to the exchange after
receiving SubscribeResponse, so it would attempt to abort
already closed exchange if the subscription was cancelled
after receiving the SubscribeResponse and before receving
a subsequent Report message.
  • Loading branch information
Damian-Nordic committed Oct 29, 2021
1 parent 2475f10 commit 0f5c6d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ CHIP_ERROR ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchange
{
VerifyOrExit(apExchangeContext == mpExchangeCtx, err = CHIP_ERROR_INCORRECT_STATE);
err = ProcessSubscribeResponse(std::move(aPayload));
// Forget the context as SUBSCRIBE RESPONSE is the last message in SUBSCRIBE transaction and
// ExchangeContext::HandleMessage automatically closes a context if other messages need to
// be sent or received.
mpExchangeCtx = nullptr;
SuccessOrExit(err);
}
else
Expand Down

0 comments on commit 0f5c6d3

Please sign in to comment.