diff --git a/build b/build index d8263ee9..bf0d87ab 100644 --- a/build +++ b/build @@ -1 +1 @@ -2 \ No newline at end of file +4 \ No newline at end of file diff --git a/src/AP_WS_Connection.h b/src/AP_WS_Connection.h index 82352cbf..e56a9d99 100644 --- a/src/AP_WS_Connection.h +++ b/src/AP_WS_Connection.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include #include "Poco/JSON/Object.h" @@ -162,7 +162,7 @@ namespace OpenWifi { private: mutable std::mutex ConnectionMutex_; - std::shared_mutex TelemetryMutex_; + std::mutex TelemetryMutex_; Poco::Logger &Logger_; Poco::Net::SocketReactor &Reactor_; std::unique_ptr WS_; diff --git a/src/AP_WS_ReactorPool.h b/src/AP_WS_ReactorPool.h index 21f580b3..725438d8 100644 --- a/src/AP_WS_ReactorPool.h +++ b/src/AP_WS_ReactorPool.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include #include "Poco/Environment.h" @@ -46,14 +46,14 @@ namespace OpenWifi { } Poco::Net::SocketReactor &NextReactor() { - std::shared_lock Lock(Mutex_); + std::lock_guard Lock(Mutex_); NextReactor_++; NextReactor_ %= NumberOfThreads_; return *Reactors_[NextReactor_]; } private: - std::shared_mutex Mutex_; + std::mutex Mutex_; uint64_t NumberOfThreads_; uint64_t NextReactor_ = 0; std::vector> Reactors_; diff --git a/src/CommandManager.h b/src/CommandManager.h index ef71cc19..49862c18 100644 --- a/src/CommandManager.h +++ b/src/CommandManager.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include "Poco/JSON/Object.h" @@ -165,7 +165,7 @@ namespace OpenWifi { bool FireAndForget(const std::string &SerialNumber, const std::string &Method, const Poco::JSON::Object &Params); private: - mutable std::recursive_mutex LocalMutex_; + mutable std::mutex LocalMutex_; std::atomic_bool Running_ = false; Poco::Thread ManagerThread; std::atomic_uint64_t Id_ = 3; // do not start @1. We ignore ID=1 & 0 is illegal.. diff --git a/src/OUIServer.cpp b/src/OUIServer.cpp index aed6e6b3..8c56fb1d 100644 --- a/src/OUIServer.cpp +++ b/src/OUIServer.cpp @@ -28,7 +28,7 @@ namespace OpenWifi { bool Recovered = false; Poco::File OuiFile(CurrentOUIFileName_); if (OuiFile.exists()) { - std::unique_lock Lock(LocalMutex_); + std::lock_guard Lock(LocalMutex_); Recovered = ProcessFile(CurrentOUIFileName_, OUIs_); if (Recovered) { poco_notice(Logger(), @@ -150,7 +150,7 @@ namespace OpenWifi { OUIMap TmpOUIs; if (GetFile(LatestOUIFileName_) && ProcessFile(LatestOUIFileName_, TmpOUIs)) { - std::unique_lock G(LocalMutex_); + std::lock_guard G(LocalMutex_); OUIs_ = std::move(TmpOUIs); LastUpdate_ = Utils::Now(); Poco::File F1(CurrentOUIFileName_); @@ -163,7 +163,7 @@ namespace OpenWifi { } else if (OUIs_.empty()) { if (ProcessFile(CurrentOUIFileName_, TmpOUIs)) { LastUpdate_ = Utils::Now(); - std::unique_lock G(LocalMutex_); + std::lock_guard G(LocalMutex_); OUIs_ = std::move(TmpOUIs); } } @@ -173,7 +173,7 @@ namespace OpenWifi { } std::string OUIServer::GetManufacturer(const std::string &MAC) { - std::shared_lock Lock(LocalMutex_); + std::lock_guard Lock(LocalMutex_); auto Manufacturer = OUIs_.find(Utils::SerialNumberToOUI(MAC)); if (Manufacturer != OUIs_.end()) diff --git a/src/OUIServer.h b/src/OUIServer.h index 730cca4c..ddef73a2 100644 --- a/src/OUIServer.h +++ b/src/OUIServer.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "framework/SubSystemServer.h" @@ -32,7 +32,7 @@ namespace OpenWifi { [[nodiscard]] bool ProcessFile(const std::string &FileName, OUIMap &Map); private: - std::shared_mutex LocalMutex_; + std::mutex LocalMutex_; uint64_t LastUpdate_ = 0; bool Initialized_ = false; OUIMap OUIs_; diff --git a/src/SignatureMgr.h b/src/SignatureMgr.h index 8fa592a6..aff29ef2 100644 --- a/src/SignatureMgr.h +++ b/src/SignatureMgr.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include "framework/MicroServiceFuncs.h" #include "framework/SubSystemServer.h" @@ -38,7 +38,7 @@ namespace OpenWifi { inline int Start() final { poco_notice(Logger(), "Starting..."); - std::shared_lock L(KeyMutex_); + std::lock_guard L(KeyMutex_); CacheFilename_ = MicroServiceDataDirectory() + "/signature_cache"; Poco::File CacheFile(CacheFilename_); @@ -91,7 +91,7 @@ namespace OpenWifi { inline std::string Sign(const GWObjects::DeviceRestrictions &Restrictions, const std::string &Data) const { - std::shared_lock L(KeyMutex_); + std::lock_guard L(KeyMutex_); try { if (Restrictions.key_info.algo == "static") { return "aaaaaaaaaa"; @@ -120,7 +120,7 @@ namespace OpenWifi { inline std::string Sign(const GWObjects::DeviceRestrictions &Restrictions, const Poco::URI &uri) { - std::shared_lock L(KeyMutex_); + std::lock_guard L(KeyMutex_); try { if (Restrictions.key_info.algo == "static") { return "aaaaaaaaaa"; @@ -172,7 +172,7 @@ namespace OpenWifi { } private: - mutable std::shared_mutex KeyMutex_; + mutable std::mutex KeyMutex_; std::map> Keys_; std::map SignatureCache_; std::string CacheFilename_;