From 68ccc4da9339edfebb9c07af941521c53a03d621 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sat, 2 Dec 2023 13:27:29 -0800 Subject: [PATCH 1/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- build | 2 +- src/framework/MicroService.cpp | 3 +- src/framework/StorageClass.h | 2 + src/framework/utils.h | 85 ++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) diff --git a/build b/build index d8263ee9..e440e5c8 100644 --- a/build +++ b/build @@ -1 +1 @@ -2 \ No newline at end of file +3 \ No newline at end of file diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 5d517d9f..26fb521a 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -136,7 +136,8 @@ namespace OpenWifi { auto i = Services_.begin(); auto now = Utils::Now(); for (; i != Services_.end();) { - if ((now - i->second.LastUpdate) > 60) { + if ((now - i->second.LastUpdate) > 120) { + poco_warning(logger(), fmt::format("ZombieService: Removing service {}, ", i->second.PublicEndPoint)); i = Services_.erase(i); } else ++i; diff --git a/src/framework/StorageClass.h b/src/framework/StorageClass.h index cfb55304..36751bc6 100644 --- a/src/framework/StorageClass.h +++ b/src/framework/StorageClass.h @@ -47,6 +47,8 @@ namespace OpenWifi { } + Poco::Data::SessionPool &Pool() { return *Pool_; } + private: inline int Setup_SQLite(); inline int Setup_MySQL(); diff --git a/src/framework/utils.h b/src/framework/utils.h index fa0d58d1..b20d32af 100644 --- a/src/framework/utils.h +++ b/src/framework/utils.h @@ -316,5 +316,90 @@ namespace OpenWifi::Utils { uint32_t Port; }; + class CompressedString { + public: + CompressedString() { + DecompressedSize_ = 0; + }; + + explicit CompressedString(const std::string &Data) : DecompressedSize_(Data.size()) { + CompressIt(Data); + } + + CompressedString(const CompressedString &Data) { + this->DecompressedSize_ = Data.DecompressedSize_; + this->CompressedData_ = Data.CompressedData_; + } + + CompressedString& operator=(const CompressedString& rhs) { + if (this != &rhs) { + this->DecompressedSize_ = rhs.DecompressedSize_; + this->CompressedData_ = rhs.CompressedData_; + } + return *this; + } + + CompressedString& operator=(CompressedString&& rhs) { + if (this != &rhs) { + this->DecompressedSize_ = rhs.DecompressedSize_; + this->CompressedData_ = rhs.CompressedData_; + } + return *this; + } + + ~CompressedString() = default; + + operator std::string() const { + return DecompressIt(); + } + + CompressedString &operator=(const std::string &Data) { + DecompressedSize_ = Data.size(); + CompressIt(Data); + return *this; + } + + auto CompressedSize() const { return CompressedData_.size(); } + auto DecompressedSize() const { return DecompressedSize_; } + + private: + std::string CompressedData_; + std::size_t DecompressedSize_; + + inline void CompressIt(const std::string &Data) { + z_stream strm; // = {0}; + CompressedData_.resize(Data.size()); + strm.next_in = (Bytef *)Data.data(); + strm.avail_in = Data.size(); + strm.next_out = (Bytef *)CompressedData_.data(); + strm.avail_out = Data.size(); + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); + deflate(&strm, Z_FINISH); + deflateEnd(&strm); + CompressedData_.resize(strm.total_out); + } + + [[nodiscard]] std::string DecompressIt() const { + std::string Result; + if(DecompressedSize_!=0) { + Result.resize(DecompressedSize_); + z_stream strm ; //= {0}; + strm.next_in = (Bytef *)CompressedData_.data(); + strm.avail_in = CompressedData_.size(); + strm.next_out = (Bytef *)Result.data(); + strm.avail_out = Result.size(); + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + inflateInit2(&strm, 15 + 32); + inflate(&strm, Z_FINISH); + inflateEnd(&strm); + } + return Result; + } + }; } // namespace OpenWifi::Utils From 2b01453970749e8f8d44aae29eb6cbcc2be7b3f2 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 3 Dec 2023 10:11:58 -0800 Subject: [PATCH 2/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- src/framework/MicroService.cpp | 68 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 26fb521a..12c47176 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -55,12 +55,9 @@ namespace OpenWifi { Object->has(KafkaTopics::ServiceEvents::Fields::KEY)) { auto PrivateEndPoint = Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(); - if (Event == KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE && - Services_.find(PrivateEndPoint) != Services_.end()) { - Services_[PrivateEndPoint].LastUpdate = Utils::Now(); - } else if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) { + if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) { Services_.erase(PrivateEndPoint); - poco_debug( + poco_information( logger(), fmt::format( "Service {} ID={} leaving system.", @@ -69,14 +66,7 @@ namespace OpenWifi { ID)); } else if (Event == KafkaTopics::ServiceEvents::EVENT_JOIN || Event == KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE) { - poco_debug( - logger(), - fmt::format( - "Service {} ID={} joining system.", - Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) - .toString(), - ID)); - Services_[PrivateEndPoint] = Types::MicroServiceMeta{ + auto ServiceInfo = Types::MicroServiceMeta{ .Id = ID, .Type = Poco::toLower( Object->get(KafkaTopics::ServiceEvents::Fields::TYPE) @@ -94,19 +84,29 @@ namespace OpenWifi { .toString(), .LastUpdate = Utils::Now()}; - std::string SvcList; - for (const auto &Svc : Services_) { - if (SvcList.empty()) - SvcList = Svc.second.Type; - else - SvcList += ", " + Svc.second.Type; + Services_[PrivateEndPoint] = ServiceInfo; + if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) { + poco_information( + logger(), + fmt::format( + "Service {} ID={} is joining the system.", + Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) + .toString(), + ID)); + std::string SvcList; + for (const auto &Svc : Services_) { + if (SvcList.empty()) + SvcList = Svc.second.Type; + else + SvcList += ", " + Svc.second.Type; + } + poco_information( + logger(), + fmt::format("Current list of microservices: {}", SvcList)); } - poco_information( - logger(), - fmt::format("Current list of microservices: {}", SvcList)); } } else { - poco_error( + poco_information( logger(), fmt::format("KAFKA-MSG: invalid event '{}', missing a field.", Event)); @@ -118,29 +118,29 @@ namespace OpenWifi { Object->get(KafkaTopics::ServiceEvents::Fields::TOKEN).toString()); #endif } else { - poco_error( + poco_information( logger(), fmt::format("KAFKA-MSG: invalid event '{}', missing token", Event)); } } else { - poco_error(logger(), + poco_information(logger(), fmt::format("Unknown Event: {} Source: {}", Event, ID)); } } } else { - poco_error(logger(), "Bad bus message."); - std::ostringstream os; - Object->stringify(std::cout); + std::ostringstream os; + Object->stringify(std::cout); + poco_error(logger(), fmt::format("Bad bus message: {}", os.str())); } - auto i = Services_.begin(); + auto ServiceHint = Services_.begin(); auto now = Utils::Now(); - for (; i != Services_.end();) { - if ((now - i->second.LastUpdate) > 120) { - poco_warning(logger(), fmt::format("ZombieService: Removing service {}, ", i->second.PublicEndPoint)); - i = Services_.erase(i); + while(ServiceHint!=Services_.end()) { + if ((now - ServiceHint->second.LastUpdate) > 120) { + poco_information(logger(), fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint)); + ServiceHint = Services_.erase(ServiceHint); } else - ++i; + ++ServiceHint; } } catch (const Poco::Exception &E) { From d2f70ec82d4e751da6a5df304c347e34ac14d512 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 3 Dec 2023 10:46:50 -0800 Subject: [PATCH 3/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- src/framework/MicroService.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 12c47176..70f92577 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -33,6 +33,17 @@ namespace OpenWifi { void MicroService::Exit(int Reason) { std::exit(Reason); } + static std::string MakeServiceListString(const Types::MicroServiceMetaMap &Services) { + std::string SvcList; + for (const auto &Svc : Services) { + if (SvcList.empty()) + SvcList = Svc.second.Type; + else + SvcList += ", " + Svc.second.Type; + } + return SvcList; + } + void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key, const std::string &Payload) { std::lock_guard G(InfraMutex_); @@ -84,15 +95,16 @@ namespace OpenWifi { .toString(), .LastUpdate = Utils::Now()}; + auto s1 = MakeServiceListString(Services_); Services_[PrivateEndPoint] = ServiceInfo; if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) { - poco_information( + poco_information( logger(), fmt::format( - "Service {} ID={} is joining the system.", + "Service {} ID={} is joining the system. old={}", Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) .toString(), - ID)); + ID, s1)); std::string SvcList; for (const auto &Svc : Services_) { if (SvcList.empty()) @@ -135,13 +147,19 @@ namespace OpenWifi { auto ServiceHint = Services_.begin(); auto now = Utils::Now(); + auto si1 = Services_.size(); + auto ss1 = MakeServiceListString(Services_); while(ServiceHint!=Services_.end()) { if ((now - ServiceHint->second.LastUpdate) > 120) { - poco_information(logger(), fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint)); + poco_information(Logger_, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint)); ServiceHint = Services_.erase(ServiceHint); } else ++ServiceHint; } + if(Services_.size() != si1) { + auto ss2 = MakeServiceListString(Services_); + poco_information(Logger_, fmt::format("Current list of microservices: {} -> {}", ss1, ss2)); + } } catch (const Poco::Exception &E) { logger().log(E); From db45a01bce98a28c9d310d528532099eee2ce9a7 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 3 Dec 2023 12:03:02 -0800 Subject: [PATCH 4/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- build | 2 +- src/framework/MicroService.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build b/build index e440e5c8..bf0d87ab 100644 --- a/build +++ b/build @@ -1 +1 @@ -3 \ No newline at end of file +4 \ No newline at end of file diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 70f92577..30460fe2 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -69,7 +69,7 @@ namespace OpenWifi { if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) { Services_.erase(PrivateEndPoint); poco_information( - logger(), + Logger_, fmt::format( "Service {} ID={} leaving system.", Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) @@ -99,7 +99,7 @@ namespace OpenWifi { Services_[PrivateEndPoint] = ServiceInfo; if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) { poco_information( - logger(), + Logger_, fmt::format( "Service {} ID={} is joining the system. old={}", Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) @@ -113,13 +113,13 @@ namespace OpenWifi { SvcList += ", " + Svc.second.Type; } poco_information( - logger(), + Logger_, fmt::format("Current list of microservices: {}", SvcList)); } } } else { poco_information( - logger(), + Logger_, fmt::format("KAFKA-MSG: invalid event '{}', missing a field.", Event)); } @@ -131,18 +131,18 @@ namespace OpenWifi { #endif } else { poco_information( - logger(), + Logger_, fmt::format("KAFKA-MSG: invalid event '{}', missing token", Event)); } } else { - poco_information(logger(), + poco_information(Logger_, fmt::format("Unknown Event: {} Source: {}", Event, ID)); } } } else { std::ostringstream os; Object->stringify(std::cout); - poco_error(logger(), fmt::format("Bad bus message: {}", os.str())); + poco_error(Logger_, fmt::format("Bad bus message: {}", os.str())); } auto ServiceHint = Services_.begin(); @@ -162,7 +162,7 @@ namespace OpenWifi { } } catch (const Poco::Exception &E) { - logger().log(E); + Logger_.log(E); } } @@ -431,7 +431,7 @@ namespace OpenWifi { try { DataDir.createDirectory(); } catch (const Poco::Exception &E) { - logger().log(E); + Logger_.log(E); } } WWWAssetsDir_ = ConfigPath("openwifi.restapi.wwwassets", ""); @@ -716,7 +716,7 @@ namespace OpenWifi { auto APIKEY = Request.get("X-API-KEY"); return APIKEY == MyHash_; } catch (const Poco::Exception &E) { - logger().log(E); + Logger_.log(E); } return false; } From 5b3205823e3d3c43243085e2d7f38d6ee12e0579 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sun, 3 Dec 2023 13:23:20 -0800 Subject: [PATCH 5/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- src/framework/MicroService.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 30460fe2..6c1aed37 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -47,6 +47,9 @@ namespace OpenWifi { void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key, const std::string &Payload) { std::lock_guard G(InfraMutex_); + + Poco::Logger &BusLogger = Poco::Logger::create( + "BusMessageReceived", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel()); try { Poco::JSON::Parser P; auto Object = P.parse(Payload).extract(); @@ -69,7 +72,7 @@ namespace OpenWifi { if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) { Services_.erase(PrivateEndPoint); poco_information( - Logger_, + BusLogger, fmt::format( "Service {} ID={} leaving system.", Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) @@ -99,7 +102,7 @@ namespace OpenWifi { Services_[PrivateEndPoint] = ServiceInfo; if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) { poco_information( - Logger_, + BusLogger, fmt::format( "Service {} ID={} is joining the system. old={}", Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) @@ -113,13 +116,13 @@ namespace OpenWifi { SvcList += ", " + Svc.second.Type; } poco_information( - Logger_, + BusLogger, fmt::format("Current list of microservices: {}", SvcList)); } } } else { poco_information( - Logger_, + BusLogger, fmt::format("KAFKA-MSG: invalid event '{}', missing a field.", Event)); } @@ -131,18 +134,18 @@ namespace OpenWifi { #endif } else { poco_information( - Logger_, + BusLogger, fmt::format("KAFKA-MSG: invalid event '{}', missing token", Event)); } } else { - poco_information(Logger_, + poco_information(BusLogger, fmt::format("Unknown Event: {} Source: {}", Event, ID)); } } } else { std::ostringstream os; Object->stringify(std::cout); - poco_error(Logger_, fmt::format("Bad bus message: {}", os.str())); + poco_error(BusLogger, fmt::format("Bad bus message: {}", os.str())); } auto ServiceHint = Services_.begin(); @@ -151,18 +154,18 @@ namespace OpenWifi { auto ss1 = MakeServiceListString(Services_); while(ServiceHint!=Services_.end()) { if ((now - ServiceHint->second.LastUpdate) > 120) { - poco_information(Logger_, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint)); + poco_information(BusLogger, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint)); ServiceHint = Services_.erase(ServiceHint); } else ++ServiceHint; } if(Services_.size() != si1) { auto ss2 = MakeServiceListString(Services_); - poco_information(Logger_, fmt::format("Current list of microservices: {} -> {}", ss1, ss2)); + poco_information(BusLogger, fmt::format("Current list of microservices: {} -> {}", ss1, ss2)); } } catch (const Poco::Exception &E) { - Logger_.log(E); + BusLogger.log(E); } } From 6a7ae342dcf2039e1d4837de827969675afc6e6f Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 4 Dec 2023 07:40:29 -0800 Subject: [PATCH 6/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- build | 2 +- src/framework/EventBusManager.cpp | 2 -- src/framework/EventBusManager.h | 12 ++++++++++++ src/framework/MicroService.cpp | 10 ++++------ src/framework/MicroService.h | 1 - 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/build b/build index bf0d87ab..7813681f 100644 --- a/build +++ b/build @@ -1 +1 @@ -4 \ No newline at end of file +5 \ No newline at end of file diff --git a/src/framework/EventBusManager.cpp b/src/framework/EventBusManager.cpp index ca28ad94..66774f1e 100644 --- a/src/framework/EventBusManager.cpp +++ b/src/framework/EventBusManager.cpp @@ -9,8 +9,6 @@ namespace OpenWifi { - EventBusManager::EventBusManager(Poco::Logger &L) : Logger_(L) {} - void EventBusManager::run() { Running_ = true; Utils::SetThreadName("fmwk:EventMgr"); diff --git a/src/framework/EventBusManager.h b/src/framework/EventBusManager.h index 9a7316e9..fe8a82cb 100644 --- a/src/framework/EventBusManager.h +++ b/src/framework/EventBusManager.h @@ -12,6 +12,16 @@ namespace OpenWifi { class EventBusManager : public Poco::Runnable { public: + EventBusManager() : + Logger_(Poco::Logger::create( + "EventBusManager", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel())) { + } + + static auto instance() { + static auto instance_ = new EventBusManager; + return instance_; + } + explicit EventBusManager(Poco::Logger &L); void run() final; void Start(); @@ -24,4 +34,6 @@ namespace OpenWifi { Poco::Logger &Logger_; }; + inline auto EventBusManager() { return EventBusManager::instance(); } + } // namespace OpenWifi diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index 6c1aed37..fabc65bb 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -48,8 +48,8 @@ namespace OpenWifi { const std::string &Payload) { std::lock_guard G(InfraMutex_); - Poco::Logger &BusLogger = Poco::Logger::create( - "BusMessageReceived", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel()); + Poco::Logger &BusLogger = EventBusManager()->Logger(); + try { Poco::JSON::Parser P; auto Object = P.parse(Payload).extract(); @@ -552,14 +552,12 @@ namespace OpenWifi { for (auto i : SubSystems_) { i->Start(); } - EventBusManager_ = std::make_unique(Poco::Logger::create( - "EventBusManager", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel())); - EventBusManager_->Start(); + EventBusManager()->Start(); } void MicroService::StopSubSystemServers() { AddActivity("Stopping"); - EventBusManager_->Stop(); + EventBusManager()->Stop(); for (auto i = SubSystems_.rbegin(); i != SubSystems_.rend(); ++i) { (*i)->Stop(); } diff --git a/src/framework/MicroService.h b/src/framework/MicroService.h index 00532b47..7290bbbb 100644 --- a/src/framework/MicroService.h +++ b/src/framework/MicroService.h @@ -201,7 +201,6 @@ namespace OpenWifi { Poco::JWT::Signer Signer_; Poco::Logger &Logger_; Poco::ThreadPool TimerPool_{"timer:pool", 2, 32}; - std::unique_ptr EventBusManager_; }; inline MicroService *MicroService::instance_ = nullptr; From 9eec54effb9d9d31866b2dafec499c866fe06e74 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 4 Dec 2023 08:31:55 -0800 Subject: [PATCH 7/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- src/framework/MicroService.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/framework/MicroService.cpp b/src/framework/MicroService.cpp index fabc65bb..13f89fbf 100644 --- a/src/framework/MicroService.cpp +++ b/src/framework/MicroService.cpp @@ -99,15 +99,21 @@ namespace OpenWifi { .LastUpdate = Utils::Now()}; auto s1 = MakeServiceListString(Services_); + auto PreviousSize = Services_.size(); Services_[PrivateEndPoint] = ServiceInfo; + auto CurrentSize = Services_.size(); if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) { - poco_information( - BusLogger, - fmt::format( - "Service {} ID={} is joining the system. old={}", - Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) - .toString(), - ID, s1)); + if(!s1.empty()) { + poco_information( + BusLogger, + fmt::format( + "Service {} ID={} is joining the system.", + Object + ->get( + KafkaTopics::ServiceEvents::Fields::PRIVATE) + .toString(), + ID)); + } std::string SvcList; for (const auto &Svc : Services_) { if (SvcList.empty()) @@ -118,6 +124,15 @@ namespace OpenWifi { poco_information( BusLogger, fmt::format("Current list of microservices: {}", SvcList)); + } else if(CurrentSize!=PreviousSize) { + poco_information( + BusLogger, + fmt::format( + "Service {} ID={} is being added back in.", + Object + ->get(KafkaTopics::ServiceEvents::Fields::PRIVATE) + .toString(), + ID)); } } } else { From e3592b5fe607d17cb64f9e194cef4cb88f09169a Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 5 Dec 2023 07:16:32 -0800 Subject: [PATCH 8/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- src/AuthService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuthService.cpp b/src/AuthService.cpp index a904f9b0..0a326758 100644 --- a/src/AuthService.cpp +++ b/src/AuthService.cpp @@ -218,7 +218,7 @@ namespace OpenWifi { Expired = (WT.created_ + WT.expires_in_) < now; if (StorageService()->UserDB().GetUserById(UserId, UInfo.userinfo)) { UInfo.webtoken = WT; - poco_debug(Logger(), fmt::format("TokenValidation success for TID={} Token={}", + poco_trace(Logger(), fmt::format("TokenValidation success for TID={} Token={}", TID, Utils::SanitizeToken(CallToken))); return true; } From d050635a99502d07d483e22a65cdcc23ad341b8d Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Mon, 11 Dec 2023 09:47:33 -0800 Subject: [PATCH 9/9] https://telecominfraproject.atlassian.net/browse/WIFI-13172 Signed-off-by: stephb9959 --- build | 2 +- src/framework/orm.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build b/build index 7813681f..62f94575 100644 --- a/build +++ b/build @@ -1 +1 @@ -5 \ No newline at end of file +6 \ No newline at end of file diff --git a/src/framework/orm.h b/src/framework/orm.h index 9e83540f..c0be1373 100644 --- a/src/framework/orm.h +++ b/src/framework/orm.h @@ -576,8 +576,8 @@ namespace ORM { bool UpdateRecord(field_name_t FieldName, const T &Value, const RecordType &R) { try { assert(ValidFieldName(FieldName)); - Poco::Data::Session Session = Pool_.get(); + Session.begin(); Poco::Data::Statement Update(Session); RecordTuple RT; @@ -593,6 +593,7 @@ namespace ORM { Update.execute(); if (Cache_) Cache_->UpdateCache(R); + Session.commit(); return true; } catch (const Poco::Exception &E) { Logger_.log(E); @@ -662,6 +663,7 @@ namespace ORM { assert(ValidFieldName(FieldName)); Poco::Data::Session Session = Pool_.get(); + Session.begin(); Poco::Data::Statement Delete(Session); std::string St = "delete from " + TableName_ + " where " + FieldName + "=?"; @@ -671,6 +673,7 @@ namespace ORM { Delete.execute(); if (Cache_) Cache_->Delete(FieldName, Value); + Session.commit(); return true; } catch (const Poco::Exception &E) { Logger_.log(E); @@ -682,11 +685,13 @@ namespace ORM { try { assert(!WhereClause.empty()); Poco::Data::Session Session = Pool_.get(); + Session.begin(); Poco::Data::Statement Delete(Session); std::string St = "delete from " + TableName_ + " where " + WhereClause; Delete << St; Delete.execute(); + Session.commit(); return true; } catch (const Poco::Exception &E) { Logger_.log(E);