Skip to content

Commit 00c52de

Browse files
Moved the IM shutdown before setting data model provider to null in the
server shutdown sequence.
1 parent 4f4e607 commit 00c52de

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/app/InteractionModelEngine.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ void InteractionModelEngine::Shutdown()
198198

199199
mTimedHandlers.ReleaseAll();
200200

201-
mReadHandlers.ReleaseAll();
202-
203201
#if CHIP_CONFIG_ENABLE_READ_CLIENT
204202
// Shut down any subscription clients that are still around. They won't be
205203
// able to work after this point anyway, since we're about to drop our refs
@@ -220,6 +218,7 @@ void InteractionModelEngine::Shutdown()
220218
readClient->mpImEngine = nullptr;
221219
auto * tmpClient = readClient->GetNextClient();
222220
readClient->SetNextClient(nullptr);
221+
readClient->Close(CHIP_NO_ERROR);
223222
readClient = tmpClient;
224223
}
225224

@@ -229,6 +228,7 @@ void InteractionModelEngine::Shutdown()
229228
mpActiveReadClientList = nullptr;
230229
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT
231230

231+
mReadHandlers.ReleaseAll();
232232
for (auto & writeHandler : mWriteHandlers)
233233
{
234234
if (!writeHandler.IsFree())
@@ -1865,15 +1865,15 @@ Protocols::InteractionModel::Status InteractionModelEngine::CheckCommandExistenc
18651865

18661866
DataModel::Provider * InteractionModelEngine::SetDataModelProvider(DataModel::Provider * model)
18671867
{
1868-
// Altering data model should not be done while IM is actively handling requests.
1869-
VerifyOrDie(mReadHandlers.begin() == mReadHandlers.end());
1870-
18711868
if (model == mDataModelProvider)
18721869
{
18731870
// no-op, just return
18741871
return model;
18751872
}
18761873

1874+
// Altering data model should not be done while IM is actively handling requests.
1875+
VerifyOrDie(mReadHandlers.begin() == mReadHandlers.end());
1876+
18771877
DataModel::Provider * oldModel = mDataModelProvider;
18781878
if (oldModel != nullptr)
18791879
{

src/app/server/Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ void Server::Shutdown()
652652
app::DnssdServer::Instance().SetICDManager(nullptr);
653653
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
654654

655+
app::InteractionModelEngine::GetInstance()->Shutdown();
655656
app::InteractionModelEngine::GetInstance()->SetDataModelProvider(nullptr);
656657
app::DnssdServer::Instance().SetCommissioningModeProvider(nullptr);
657658
Dnssd::ServiceAdvertiser::Instance().Shutdown();
@@ -670,7 +671,6 @@ void Server::Shutdown()
670671
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY
671672

672673
Dnssd::Resolver::Instance().Shutdown();
673-
app::InteractionModelEngine::GetInstance()->Shutdown();
674674
#if CHIP_CONFIG_ENABLE_ICD_SERVER
675675
app::InteractionModelEngine::GetInstance()->SetICDManager(nullptr);
676676
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

0 commit comments

Comments
 (0)