Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13172
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Nov 22, 2023
1 parent 77ee9d4 commit 4bc1ac1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2
4
4 changes: 2 additions & 2 deletions src/AP_WS_Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <shared_mutex>
#include <mutex>
#include <string>

#include "Poco/JSON/Object.h"
Expand Down Expand Up @@ -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<Poco::Net::WebSocket> WS_;
Expand Down
6 changes: 3 additions & 3 deletions src/AP_WS_ReactorPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <shared_mutex>
#include <mutex>
#include <string>

#include "Poco/Environment.h"
Expand Down Expand Up @@ -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<std::unique_ptr<Poco::Net::SocketReactor>> Reactors_;
Expand Down
4 changes: 2 additions & 2 deletions src/CommandManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <functional>
#include <future>
#include <map>
#include <shared_mutex>
#include <mutex>
#include <utility>

#include "Poco/JSON/Object.h"
Expand Down Expand Up @@ -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..
Expand Down
8 changes: 4 additions & 4 deletions src/OUIServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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_);
Expand All @@ -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);
}
}
Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions src/OUIServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include <shared_mutex>
#include <mutex>

#include "framework/SubSystemServer.h"

Expand Down Expand Up @@ -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_;
Expand Down
10 changes: 5 additions & 5 deletions src/SignatureMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <fstream>
#include <shared_mutex>
#include <mutex>

#include "framework/MicroServiceFuncs.h"
#include "framework/SubSystemServer.h"
Expand Down Expand Up @@ -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_);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace OpenWifi {
}

private:
mutable std::shared_mutex KeyMutex_;
mutable std::mutex KeyMutex_;
std::map<std::string, Poco::SharedPtr<Poco::Crypto::RSAKey>> Keys_;
std::map<std::string, std::string> SignatureCache_;
std::string CacheFilename_;
Expand Down

0 comments on commit 4bc1ac1

Please sign in to comment.