Skip to content

Commit 5a0e3ce

Browse files
authored
Implement chip::Access::AccessControl::ResetAccessControl (project-chip#23416)
* 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 project-chip#23415 * Per Andrei Litvin, s/ResetAccessControl/ResetAccessControlToDefault
1 parent 5bf3e3f commit 5a0e3ce

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

src/access/AccessControl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -632,5 +632,10 @@ void SetAccessControl(AccessControl & accessControl)
632632
globalAccessControl = &accessControl;
633633
}
634634

635+
void ResetAccessControlToDefault()
636+
{
637+
globalAccessControl = &defaultAccessControl;
638+
}
639+
635640
} // namespace Access
636641
} // namespace chip

src/access/AccessControl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ void SetAccessControl(AccessControl & accessControl);
683683
*
684684
* Calls to this function must be synchronized externally.
685685
*/
686-
void ResetAccessControl();
686+
void ResetAccessControlToDefault();
687687

688688
} // namespace Access
689689
} // namespace chip

src/access/tests/TestAccessControl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,7 @@ int Setup(void * inContext)
21732173
int Teardown(void * inContext)
21742174
{
21752175
GetAccessControl().Finish();
2176+
ResetAccessControlToDefault();
21762177
return SUCCESS;
21772178
}
21782179

src/app/server/Server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ void Server::Shutdown()
430430
mSessions.Shutdown();
431431
mTransports.Close();
432432
mAccessControl.Finish();
433+
Access::ResetAccessControlToDefault();
433434
Credentials::SetGroupDataProvider(nullptr);
434435
mAttributePersister.Shutdown();
435436
// TODO(16969): Remove chip::Platform::MemoryInit() call from Server class, it belongs to outer code

src/app/tests/AppTestContext.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CHIP_ERROR AppContext::Init()
5252
void AppContext::Shutdown()
5353
{
5454
Access::GetAccessControl().Finish();
55+
Access::ResetAccessControlToDefault();
5556

5657
chip::app::InteractionModelEngine::GetInstance()->Shutdown();
5758
Super::Shutdown();

0 commit comments

Comments
 (0)