Skip to content

Commit

Permalink
Persist mNextKeyID immediately instead of relying on teardown mechani…
Browse files Browse the repository at this point in the history
…sms (#6565)
  • Loading branch information
sagar-apple authored and pull[bot] committed Jul 16, 2021
1 parent 8f3974f commit 6599269
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ CHIP_ERROR DeviceController::InitializePairedDeviceList()
}
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed to initialize the device list\n");
ChipLogError(Controller, "Failed to initialize the device list with error: %d\n", err);
}

return err;
Expand All @@ -584,7 +584,7 @@ CHIP_ERROR DeviceController::SetPairedDeviceList(const char * serialized)
exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed to recreate the device list\n");
ChipLogError(Controller, "Failed to recreate the device list with buffer %s\n", serialized);
}
else
{
Expand Down Expand Up @@ -666,8 +666,6 @@ CHIP_ERROR DeviceCommissioner::Shutdown()

PersistDeviceList();

FreeRendezvousSession();

DeviceController::Shutdown();
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -749,6 +747,9 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam
VerifyOrExit(exchangeCtxt != nullptr, err = CHIP_ERROR_INTERNAL);

err = mPairingSession.Pair(params.GetPeerAddress(), params.GetSetupPINCode(), mNextKeyId++, exchangeCtxt, this);
// Immediately persist the updted mNextKeyID value
// TODO maybe remove FreeRendezvousSession() since mNextKeyID is always persisted immediately
PersistNextKeyId();

exit:
if (err != CHIP_NO_ERROR)
Expand Down

0 comments on commit 6599269

Please sign in to comment.