Skip to content

Commit

Permalink
Fix initialization of device instance info providers on POSIX. (#21259)
Browse files Browse the repository at this point in the history
GenericConfigurationManagerImpl::Init sets up a generic device
instance info provider, which was overriding the platform-specific
ones that were being set in various places.

Fixes #21139
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 22, 2023
1 parent 597ac77 commit 1487616
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
#if !CHIP_DISABLE_PLATFORM_KVS
err = Internal::PosixConfig::Init();
SuccessOrExit(err);
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
#endif // CHIP_DISABLE_PLATFORM_KVS

mRunLoopSem = dispatch_semaphore_create(0);
Expand All @@ -63,6 +62,12 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
err = Internal::GenericPlatformManagerImpl<PlatformManagerImpl>::_InitChipStack();
SuccessOrExit(err);

#if !CHIP_DISABLE_PLATFORM_KVS
// Now set up our device instance info provider. We couldn't do that
// earlier, because the generic implementation sets a generic one.
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
#endif // CHIP_DISABLE_PLATFORM_KVS

mStartTime = System::SystemClock().GetMonotonicTimestamp();

static_cast<System::LayerSocketsLoop &>(DeviceLayer::SystemLayer()).SetDispatchQueue(GetWorkQueue());
Expand Down
5 changes: 4 additions & 1 deletion src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,15 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()

// Initialize the configuration system.
ReturnErrorOnFailure(Internal::PosixConfig::Init());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
ReturnErrorOnFailure(Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack());

// Now set up our device instance info provider. We couldn't do that
// earlier, because the generic implementation sets a generic one.
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

mStartTime = System::SystemClock().GetMonotonicTimestamp();

return CHIP_NO_ERROR;
Expand Down
7 changes: 6 additions & 1 deletion src/platform/Tizen/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ PlatformManagerImpl PlatformManagerImpl::sInstance;
CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
{
ReturnErrorOnFailure(Internal::PosixConfig::Init());

ReturnErrorOnFailure(Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack());

// Now set up our device instance info provider. We couldn't do that
// earlier, because the generic implementation sets a generic one.
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

return Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack();
return CHIP_NO_ERROR;
}

} // namespace DeviceLayer
Expand Down
5 changes: 4 additions & 1 deletion src/platform/android/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
// Initialize the configuration system.
err = Internal::AndroidConfig::Init();
SuccessOrExit(err);
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
err = Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack();
SuccessOrExit(err);

// Now set up our device instance info provider. We couldn't do that
// earlier, because the generic implementation sets a generic one.
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

exit:
return err;
}
Expand Down
5 changes: 4 additions & 1 deletion src/platform/webos/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,15 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()

// Initialize the configuration system.
ReturnErrorOnFailure(Internal::PosixConfig::Init());
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
ReturnErrorOnFailure(Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack());

// Now set up our device instance info provider. We couldn't do that
// earlier, because the generic implementation sets a generic one.
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());

mStartTime = System::SystemClock().GetMonotonicTimestamp();

return CHIP_NO_ERROR;
Expand Down

0 comments on commit 1487616

Please sign in to comment.