Skip to content

Commit

Permalink
Stop getting a subject descriptor from a gone-async command in Darwin…
Browse files Browse the repository at this point in the history
… OTA. (#25829)

Also grab our local node id before something has a chance to kill our exchange
or its session.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Sep 7, 2023
1 parent 68c7bed commit ebcf4dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath
return;
}

auto fabricIndex = commandObj->GetAccessingFabricIndex();
auto ourNodeId = commandObj->GetExchangeContext()->GetSessionHandle()->AsSecureSession()->GetLocalScopedNodeId();

auto * commandParams = [[MTROTASoftwareUpdateProviderClusterQueryImageParams alloc] init];
CHIP_ERROR err = ConvertToQueryImageParams(commandData, commandParams);
if (err != CHIP_NO_ERROR) {
Expand Down Expand Up @@ -666,8 +669,6 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath
}

// If there is an update available, try to prepare for a transfer.
auto fabricIndex = handler->GetSubjectDescriptor().fabricIndex;
auto nodeId = handler->GetSubjectDescriptor().subject;
CHIP_ERROR err = gOtaSender.PrepareForTransfer(fabricIndex, nodeId);
if (CHIP_NO_ERROR != err) {

Expand All @@ -694,11 +695,10 @@ bool GetPeerNodeInfo(CommandHandler * commandHandler, const ConcreteCommandPath
gOtaSender.ResetState();
return;
}
auto targetNodeId = handler->GetExchangeContext()->GetSessionHandle()->AsSecureSession()->GetLocalScopedNodeId();

char uriBuffer[kMaxBDXURILen];
MutableCharSpan uri(uriBuffer);
err = bdx::MakeURI(targetNodeId.GetNodeId(), AsCharSpan(data.imageURI), uri);
err = bdx::MakeURI(ourNodeId.GetNodeId(), AsCharSpan(data.imageURI), uri);
if (CHIP_NO_ERROR != err) {
LogErrorOnFailure(err);
handler->AddStatus(cachedCommandPath, StatusIB(err).mStatus);
Expand Down

0 comments on commit ebcf4dd

Please sign in to comment.