Skip to content

Commit

Permalink
Revert "[ota] Fix exchange context leak in OTA requestor (#20304)" (#…
Browse files Browse the repository at this point in the history
…20563)

This reverts commit 757682e.
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Jun 26, 2023
1 parent ba09f8a commit 1475288
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,12 @@ void DefaultOTARequestor::OnDownloadStateChanged(OTADownloader::State state, OTA
{
case OTADownloader::State::kComplete:
mOtaRequestorDriver->UpdateDownloaded();
mBdxMessenger.Reset();
break;
case OTADownloader::State::kIdle:
if (reason != OTAChangeReasonEnum::kSuccess)
{
RecordErrorUpdateState(CHIP_ERROR_CONNECTION_ABORTED, reason);
}
mBdxMessenger.Reset();
break;
default:
break;
Expand Down Expand Up @@ -825,10 +823,10 @@ CHIP_ERROR DefaultOTARequestor::StartDownload(OperationalDeviceProxy & devicePro
Optional<SessionHandle> session = deviceProxy.GetSecureSession();
VerifyOrReturnError(session.HasValue(), CHIP_ERROR_INCORRECT_STATE);

chip::Messaging::ExchangeContext * exchangeCtx = exchangeMgr->NewContext(session.Value(), &mBdxMessenger);
VerifyOrReturnError(exchangeCtx != nullptr, CHIP_ERROR_NO_MEMORY);
mExchangeCtx = exchangeMgr->NewContext(session.Value(), &mBdxMessenger);
VerifyOrReturnError(mExchangeCtx != nullptr, CHIP_ERROR_NO_MEMORY);

mBdxMessenger.Init(mBdxDownloader, exchangeCtx);
mBdxMessenger.Init(mBdxDownloader, mExchangeCtx);
mBdxDownloader->SetMessageDelegate(&mBdxMessenger);
mBdxDownloader->SetStateDelegate(this);

Expand Down
20 changes: 7 additions & 13 deletions src/app/clusters/ota-requestor/DefaultOTARequestor.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader::
mDownloader = downloader;
}

void Reset()
{
VerifyOrReturn(mExchangeCtx != nullptr);
mExchangeCtx->Close();
mExchangeCtx = nullptr;
}

private:
chip::Messaging::ExchangeContext * mExchangeCtx;
chip::BDXDownloader * mDownloader;
Expand Down Expand Up @@ -299,12 +292,13 @@ class DefaultOTARequestor : public OTARequestorInterface, public BDXDownloader::
*/
static void OnCommissioningCompleteRequestor(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg);

OTARequestorStorage * mStorage = nullptr;
OTARequestorDriver * mOtaRequestorDriver = nullptr;
CASESessionManager * mCASESessionManager = nullptr;
OnConnectedAction mOnConnectedAction = kQueryImage;
BDXDownloader * mBdxDownloader = nullptr; // TODO: this should be OTADownloader
BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application
OTARequestorStorage * mStorage = nullptr;
OTARequestorDriver * mOtaRequestorDriver = nullptr;
CASESessionManager * mCASESessionManager = nullptr;
OnConnectedAction mOnConnectedAction = kQueryImage;
Messaging::ExchangeContext * mExchangeCtx = nullptr;
BDXDownloader * mBdxDownloader = nullptr; // TODO: this should be OTADownloader
BDXMessenger mBdxMessenger; // TODO: ideally this is held by the application
uint8_t mUpdateTokenBuffer[kMaxUpdateTokenLen];
ByteSpan mUpdateToken;
uint32_t mCurrentVersion = 0;
Expand Down

0 comments on commit 1475288

Please sign in to comment.