Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leak when shutting down a controller with pending session setups. #26070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/app/OperationalSessionSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void OperationalSessionSetup::EnqueueConnectionCallbacks(Callback::Callback<OnDe
}
}

void OperationalSessionSetup::DequeueConnectionCallbacks(CHIP_ERROR error)
void OperationalSessionSetup::DequeueConnectionCallbacksWithoutReleasing(CHIP_ERROR error)
{
Cancelable failureReady, successReady;

Expand Down Expand Up @@ -318,6 +318,11 @@ void OperationalSessionSetup::DequeueConnectionCallbacks(CHIP_ERROR error)
cb->mCall(cb->mContext, *exchangeMgr, optionalSessionHandle.Value());
}
}
}

void OperationalSessionSetup::DequeueConnectionCallbacks(CHIP_ERROR error)
{
DequeueConnectionCallbacksWithoutReleasing(error);
VerifyOrDie(mReleaseDelegate != nullptr);
mReleaseDelegate->ReleaseSession(this);
}
Expand Down Expand Up @@ -429,6 +434,8 @@ OperationalSessionSetup::~OperationalSessionSetup()
#if CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES
CancelSessionSetupReattempt();
#endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES

DequeueConnectionCallbacksWithoutReleasing(CHIP_ERROR_CANCELLED);
}

CHIP_ERROR OperationalSessionSetup::LookupPeerAddress()
Expand Down
6 changes: 6 additions & 0 deletions src/app/OperationalSessionSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ class DLL_EXPORT OperationalSessionSetup : public SessionDelegate,
*/
void DequeueConnectionCallbacks(CHIP_ERROR error);

/*
* Like DequeueConnectionCallbacks but does not release ourselves. For use
* from our destructor.
*/
void DequeueConnectionCallbacksWithoutReleasing(CHIP_ERROR error);

/**
* Triggers a DNSSD lookup to find a usable peer address.
*/
Expand Down