Skip to content

Commit

Permalink
Stop trying to remove persisted subscriptions when we can't have any. (
Browse files Browse the repository at this point in the history
…#26039)

Specifically, for non-subscription ReadHandlers and for cases when we fail to even set up a subscription id.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jun 23, 2023
1 parent 018777b commit 1040104
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ReadHandler::~ReadHandler()
void ReadHandler::Close(CloseOptions options)
{
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
if (options == CloseOptions::kDropPersistedSubscription)
if (IsType(InteractionType::Subscribe) && options == CloseOptions::kDropPersistedSubscription)
{
auto * subscriptionResumptionStorage = InteractionModelEngine::GetInstance()->GetSubscriptionResumptionStorage();
if (subscriptionResumptionStorage)
Expand Down Expand Up @@ -177,7 +177,12 @@ void ReadHandler::OnInitialRequest(System::PacketBufferHandle && aPayload)
status = StatusIB(err).mStatus;
}
StatusResponse::Send(status, mExchangeCtx.Get(), /* aExpectResponse = */ false);
Close();
// At this point we can't have a persisted subscription, since that
// happens only when ProcessSubscribeRequest returns success. And our
// subscription id is almost certianly not actually useful at this
// point, either. So don't try to mess with persisted subscriptions in
// Close().
Close(CloseOptions::kKeepPersistedSubscription);
}
else
{
Expand Down

0 comments on commit 1040104

Please sign in to comment.