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 CommissioningWindowManager DNS UDP leak #11983

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
7 changes: 6 additions & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
}
}

void CommissioningWindowManager::Cleanup()
void CommissioningWindowManager::Shutdown()
{
StopAdvertisement();

Expand All @@ -84,6 +84,11 @@ void CommissioningWindowManager::Cleanup()

memset(&mECMPASEVerifier, 0, sizeof(mECMPASEVerifier));
memset(mECMSalt, 0, sizeof(mECMSalt));
}

void CommissioningWindowManager::Cleanup()
{
Shutdown();

// reset all advertising
app::DnssdServer::Instance().StartServer(Dnssd::CommissioningMode::kDisabled);
Expand Down
1 change: 1 addition & 0 deletions src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate
void OnSessionEstablishmentStarted() override;
void OnSessionEstablished() override;

void Shutdown();
void Cleanup();

void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event);
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void Server::Shutdown()
mExchangeMgr.Shutdown();
mSessions.Shutdown();
mTransports.Close();
mCommissioningWindowManager.Cleanup();
mCommissioningWindowManager.Shutdown();
chip::Platform::MemoryShutdown();
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/tests/TestCommissionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ void CheckCommissioningWindowManagerEnhancedWindow(nlTestSuite * suite, void *)
void TearDownTask(intptr_t context)
{
chip::Server::GetInstance().Shutdown();
chip::DeviceLayer::PlatformMgr().Shutdown();
}

const nlTest sTests[] = {
Expand Down Expand Up @@ -167,6 +166,8 @@ int TestCommissioningWindowManager()
// TODO: The platform memory was intentionally left not deinitialized so that minimal mdns can destruct
chip::DeviceLayer::PlatformMgr().ScheduleWork(TearDownTask, 0);
sleep(kTestTaskWaitSeconds);
chip::DeviceLayer::PlatformMgr().StopEventLoopTask();
chip::DeviceLayer::PlatformMgr().Shutdown();

return (nlTestRunnerStats(&theSuite));
}
Expand Down