Skip to content

Commit

Permalink
The Linux platform KVS init should ignore multiple init calls
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha-rajendran committed Mar 8, 2022
1 parent c0373bb commit 9f2e518
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/platform/Linux/CHIPLinuxStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ CHIP_ERROR ChipLinuxStorage::Init(const char * configFile)
{
CHIP_ERROR retval = CHIP_NO_ERROR;

ChipLogDetail(DeviceLayer, "ChipLinuxStorage::Init: Using KVS config file: %s", configFile);
if (mInitialized)
{
ChipLogError(DeviceLayer, "ChipLinuxStorage::Init: Attempt to re-initialize with KVS config file: %s", configFile);
return CHIP_NO_ERROR;
}

mConfigPath.assign(configFile);
retval = ChipLinuxStorageIni::Init();

Expand All @@ -76,6 +83,8 @@ CHIP_ERROR ChipLinuxStorage::Init(const char * configFile)
retval = ChipLinuxStorageIni::AddConfig(mConfigPath);
}

mInitialized = true;

return retval;
}

Expand Down
1 change: 1 addition & 0 deletions src/platform/Linux/CHIPLinuxStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ChipLinuxStorage : private ChipLinuxStorageIni
std::mutex mLock;
bool mDirty;
std::string mConfigPath;
bool mInitialized = false;
};

} // namespace Internal
Expand Down

0 comments on commit 9f2e518

Please sign in to comment.