From 93c236aa792e90a23b861bbbf8712283e3dd8878 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Thu, 4 Jan 2024 14:25:15 -0800 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-13268 Signed-off-by: stephb9959 --- src/AP_WS_LookForUpgrade.cpp | 6 +++--- src/ConfigurationCache.h | 16 ++++++++-------- src/storage/storage_device.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/AP_WS_LookForUpgrade.cpp b/src/AP_WS_LookForUpgrade.cpp index 6349b4a1..796dbeeb 100644 --- a/src/AP_WS_LookForUpgrade.cpp +++ b/src/AP_WS_LookForUpgrade.cpp @@ -11,7 +11,7 @@ namespace OpenWifi { if (UUID == 0) return false; - uint64_t GoodConfig = ConfigurationCache().CurrentConfig(SerialNumberInt_); + uint64_t GoodConfig = GetCurrentConfigurationID(SerialNumberInt_); std::cout << __LINE__ << ": " << SerialNumber_ << " INT:" << SerialNumberInt_ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl; if (GoodConfig && (GoodConfig == UUID || GoodConfig == State_.PendingUUID)) { UpgradedUUID = UUID; @@ -34,7 +34,7 @@ namespace OpenWifi { // the device already has the right UUID, we just return. if (D.UUID == UUID) { UpgradedUUID = UUID; - ConfigurationCache().Add(SerialNumberInt_, UUID); + SetCurrentConfigurationID(SerialNumberInt_, UUID); std::cout << __LINE__ << ": " << SerialNumber_ << " Set GoodConfig" << std::endl; return false; } @@ -48,7 +48,7 @@ namespace OpenWifi { D.pendingConfiguration.clear(); D.pendingConfigurationCmd.clear(); StorageService()->UpdateDevice(Session, D); - ConfigurationCache().Add(SerialNumberInt_, UUID); + SetCurrentConfigurationID(SerialNumberInt_, UUID); std::cout << __LINE__ << ": " << SerialNumber_ << " GoodConfig: " << GoodConfig << " UUID:" << UUID << " Pending:" << State_.PendingUUID << std::endl; return false; } diff --git a/src/ConfigurationCache.h b/src/ConfigurationCache.h index 5869630f..d2507eb7 100644 --- a/src/ConfigurationCache.h +++ b/src/ConfigurationCache.h @@ -16,7 +16,7 @@ namespace OpenWifi { return instance; } - inline uint64_t CurrentConfig(std::uint64_t SerialNumber) { + inline uint64_t GetCurrentConfig(std::uint64_t SerialNumber) { std::lock_guard G(Mutex_); const auto Hint = Cache_.find(SerialNumber); if (Hint == end(Cache_)) @@ -24,7 +24,7 @@ namespace OpenWifi { return Hint->second; } - inline void Add(std::uint64_t SerialNumber, uint64_t Id) { + inline void SetCurrentConfig(std::uint64_t SerialNumber, uint64_t Id) { std::lock_guard G(Mutex_); Cache_[SerialNumber] = Id; } @@ -34,15 +34,15 @@ namespace OpenWifi { std::map Cache_; }; - inline uint64_t GetCurrentConfigurationID(uint64_t SerialNumber) { - return ConfigurationCache::instance()->CurrentConfig(SerialNumber); + inline auto GetCurrentConfigurationID(std::uint64_t SerialNumber) { + return ConfigurationCache::instance()->GetCurrentConfig(SerialNumber); } - inline void SetCurrentConfigurationID(const std::string &SerialNumber, uint64_t ID) { - return ConfigurationCache::instance()->Add(Utils::SerialNumberToInt(SerialNumber), ID); + inline void SetCurrentConfigurationID(const std::string &SerialNumber, std::uint64_t ID) { + return ConfigurationCache::instance()->SetCurrentConfig(Utils::SerialNumberToInt(SerialNumber), ID); } - inline void SetCurrentConfigurationID(uint64_t SerialNumber, uint64_t ID) { - return ConfigurationCache::instance()->Add(SerialNumber, ID); + inline void SetCurrentConfigurationID(uint64_t SerialNumber, std::uint64_t ID) { + return ConfigurationCache::instance()->SetCurrentConfig(SerialNumber, ID); } } // namespace OpenWifi diff --git a/src/storage/storage_device.cpp b/src/storage/storage_device.cpp index 63bd0afc..4f869475 100644 --- a/src/storage/storage_device.cpp +++ b/src/storage/storage_device.cpp @@ -265,7 +265,7 @@ namespace OpenWifi { D.pendingUUID = 0; D.LastConfigurationChange = Utils::Now(); - ConfigurationCache().Add(Utils::SerialNumberToInt(SerialNumber), D.UUID); + SetCurrentConfigurationID(Utils::SerialNumberToInt(SerialNumber), D.UUID); Poco::Data::Session Sess = Pool_->get(); Sess.begin(); @@ -321,7 +321,7 @@ namespace OpenWifi { } D.LastConfigurationChange = Utils::Now(); - ConfigurationCache().Add(Utils::SerialNumberToInt(SerialNumber), D.UUID); + SetCurrentConfigurationID(Utils::SerialNumberToInt(SerialNumber), D.UUID); Session.begin(); Poco::Data::Statement Update(Session);