Skip to content

Commit

Permalink
Implement chip::Access::AccessControl::ResetAccessControl (#23416)
Browse files Browse the repository at this point in the history
* Implement chip::Access::AccessControl::ResetAccessControl

It is not currently possible to release the injected AccessControl
instance from the sdk's Access control singleton vendor because the
symmetric reset method for Access::SetAccessControl isn't implemented.
This commit adds the implementation.

Fixes #23415

* Per Andrei Litvin, s/ResetAccessControl/ResetAccessControlToDefault
  • Loading branch information
msandstedt authored and pull[bot] committed Aug 8, 2024
1 parent b14866a commit 1139807
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/access/AccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,10 @@ void SetAccessControl(AccessControl & accessControl)
globalAccessControl = &accessControl;
}

void ResetAccessControlToDefault()
{
globalAccessControl = &defaultAccessControl;
}

} // namespace Access
} // namespace chip
2 changes: 1 addition & 1 deletion src/access/AccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ void SetAccessControl(AccessControl & accessControl);
*
* Calls to this function must be synchronized externally.
*/
void ResetAccessControl();
void ResetAccessControlToDefault();

} // namespace Access
} // namespace chip
1 change: 1 addition & 0 deletions src/access/tests/TestAccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,7 @@ int Setup(void * inContext)
int Teardown(void * inContext)
{
GetAccessControl().Finish();
ResetAccessControlToDefault();
return SUCCESS;
}

Expand Down
1 change: 1 addition & 0 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ void Server::Shutdown()
mSessions.Shutdown();
mTransports.Close();
mAccessControl.Finish();
Access::ResetAccessControlToDefault();
Credentials::SetGroupDataProvider(nullptr);
mAttributePersister.Shutdown();
// TODO(16969): Remove chip::Platform::MemoryInit() call from Server class, it belongs to outer code
Expand Down
1 change: 1 addition & 0 deletions src/app/tests/AppTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CHIP_ERROR AppContext::Init()
void AppContext::Shutdown()
{
Access::GetAccessControl().Finish();
Access::ResetAccessControlToDefault();

chip::app::InteractionModelEngine::GetInstance()->Shutdown();
Super::Shutdown();
Expand Down

0 comments on commit 1139807

Please sign in to comment.