Use lock guards for mutex locking
This commit is contained in:
parent
d6ade55958
commit
8fb6ea0b63
@ -108,7 +108,7 @@ namespace Components
|
||||
|
||||
void Bans::LoadBans(Bans::BanList* list)
|
||||
{
|
||||
Bans::AccessMutex.lock();
|
||||
std::lock_guard<std::mutex> _(Bans::AccessMutex);
|
||||
|
||||
FileSystem::File bans("bans.json");
|
||||
|
||||
@ -161,8 +161,6 @@ namespace Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bans::AccessMutex.unlock();
|
||||
}
|
||||
|
||||
void Bans::BanClientNum(int num, std::string reason)
|
||||
|
@ -251,7 +251,7 @@ Logger::Print("Initializing BitMessage...\n");
|
||||
}
|
||||
|
||||
// Resolve our own copy to the registered PubAddr copy in BitMRC if possible
|
||||
auto resolvedAddress = FindPublicKey(address);
|
||||
auto resolvedAddress = BitMessage::FindPublicKey(address);
|
||||
if (resolvedAddress != nullptr &&
|
||||
!resolvedAddress->waitingPubKey() && !resolvedAddress->getPubEncryptionKey().empty())
|
||||
return true;
|
||||
@ -261,7 +261,7 @@ Logger::Print("Initializing BitMessage...\n");
|
||||
{
|
||||
// Request public key
|
||||
BitMessage::BMClient->getPubKey(address);
|
||||
resolvedAddress = FindPublicKey(address);
|
||||
resolvedAddress = BitMessage::FindPublicKey(address);
|
||||
}
|
||||
|
||||
BitMessage::Save();
|
||||
|
@ -80,7 +80,7 @@ namespace Components
|
||||
|
||||
void Logger::Frame()
|
||||
{
|
||||
Logger::MessageMutex.lock();
|
||||
std::lock_guard<std::mutex> _(Logger::MessageMutex);
|
||||
|
||||
for (unsigned int i = 0; i < Logger::MessageQueue.size(); ++i)
|
||||
{
|
||||
@ -93,7 +93,6 @@ namespace Components
|
||||
}
|
||||
|
||||
Logger::MessageQueue.clear();
|
||||
Logger::MessageMutex.unlock();
|
||||
}
|
||||
|
||||
void Logger::PipeOutput(void(*callback)(std::string))
|
||||
|
@ -381,7 +381,7 @@ namespace Components
|
||||
|
||||
void ServerList::Insert(Network::Address address, Utils::InfoString info)
|
||||
{
|
||||
ServerList::RefreshContainer.Mutex.lock();
|
||||
std::lock_guard<std::mutex> _(ServerList::RefreshContainer.Mutex);
|
||||
|
||||
for (auto i = ServerList::RefreshContainer.Servers.begin(); i != ServerList::RefreshContainer.Servers.end();)
|
||||
{
|
||||
@ -469,8 +469,6 @@ namespace Components
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
ServerList::RefreshContainer.Mutex.unlock();
|
||||
}
|
||||
|
||||
ServerList::ServerInfo* ServerList::GetCurrentServer()
|
||||
@ -625,7 +623,7 @@ namespace Components
|
||||
|
||||
ServerList::RefreshContainer.AwatingList = false;
|
||||
|
||||
ServerList::RefreshContainer.Mutex.lock();
|
||||
std::lock_guard<std::mutex> _(ServerList::RefreshContainer.Mutex);
|
||||
|
||||
int offset = 0;
|
||||
int count = ServerList::RefreshContainer.Servers.size();
|
||||
@ -649,8 +647,6 @@ namespace Components
|
||||
}
|
||||
|
||||
Logger::Print("Parsed %d servers from master\n", ServerList::RefreshContainer.Servers.size() - count);
|
||||
|
||||
ServerList::RefreshContainer.Mutex.unlock();
|
||||
});
|
||||
|
||||
// Set default masterServerName + port and save it
|
||||
|
@ -17,6 +17,10 @@ Assert_Size(DWORD, 4);
|
||||
Assert_Size(WORD, 2);
|
||||
Assert_Size(BYTE, 1);
|
||||
|
||||
// 128 bit integers (only x64)
|
||||
//Assert_Size(__int128, 16);
|
||||
//Assert_Size(unsigned __int128, 16);
|
||||
|
||||
// 64 bit integers
|
||||
Assert_Size(__int64, 8);
|
||||
Assert_Size(unsigned __int64, 8);
|
||||
@ -64,8 +68,8 @@ static_assert(sizeof(intptr_t) == 4 && sizeof(void*) == 4 && sizeof(size_t) == 4
|
||||
// Disable telemetry data logging
|
||||
extern "C"
|
||||
{
|
||||
void _cdecl __vcrt_initialize_telemetry_provider() {}
|
||||
void _cdecl __telemetry_main_invoke_trigger() {}
|
||||
void _cdecl __telemetry_main_return_trigger() {}
|
||||
void _cdecl __vcrt_uninitialize_telemetry_provider() {}
|
||||
void __cdecl __vcrt_initialize_telemetry_provider() {}
|
||||
void __cdecl __telemetry_main_invoke_trigger() {}
|
||||
void __cdecl __telemetry_main_return_trigger() {}
|
||||
void __cdecl __vcrt_uninitialize_telemetry_provider() {}
|
||||
};
|
||||
|
@ -136,11 +136,10 @@ namespace Utils
|
||||
|
||||
Hook* Hook::Install(bool unprotect, bool keepUnportected)
|
||||
{
|
||||
Hook::StateMutex.lock();
|
||||
std::lock_guard<std::mutex> _(Hook::StateMutex);
|
||||
|
||||
if (!Hook::Initialized || Hook::Installed)
|
||||
{
|
||||
Hook::StateMutex.unlock();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -159,8 +158,6 @@ namespace Utils
|
||||
|
||||
FlushInstructionCache(GetCurrentProcess(), Hook::Place, sizeof(Hook::Buffer));
|
||||
|
||||
Hook::StateMutex.unlock();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user