diff --git a/Core/HLE/proAdhoc.h b/Core/HLE/proAdhoc.h index 79ec9184e2..4e19591aa0 100644 --- a/Core/HLE/proAdhoc.h +++ b/Core/HLE/proAdhoc.h @@ -40,6 +40,7 @@ #include #include +#include #include "Common/Net/Resolve.h" #include "Common/Serialize/Serializer.h" diff --git a/Core/HLE/proAdhocServer.cpp b/Core/HLE/proAdhocServer.cpp index a46fb26c59..536a22b419 100644 --- a/Core/HLE/proAdhocServer.cpp +++ b/Core/HLE/proAdhocServer.cpp @@ -80,8 +80,7 @@ SceNetAdhocctlUserNode * _db_user = NULL; SceNetAdhocctlGameNode * _db_game = NULL; // Server Status -//int _status = 0; -bool adhocServerRunning = false; +std::atomic adhocServerRunning(false); std::thread adhocServerThread; // Crosslink database for cross region Adhoc play diff --git a/Core/HLE/proAdhocServer.h b/Core/HLE/proAdhocServer.h index 3773749eea..63a2897652 100644 --- a/Core/HLE/proAdhocServer.h +++ b/Core/HLE/proAdhocServer.h @@ -369,5 +369,5 @@ void update_status(); int proAdhocServerThread(int port); // (int argc, char * argv[]) //extern int _status; -extern bool adhocServerRunning; +extern std::atomic adhocServerRunning; extern std::thread adhocServerThread; diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 9f5544c24f..18e4951532 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -118,12 +118,11 @@ static int sceNetAdhocPdpRecv(int id, void* addr, void* port, void* buf, void* d void __NetAdhocShutdown() { // Kill AdhocServer Thread - if (adhocServerRunning) { - adhocServerRunning = false; - if (adhocServerThread.joinable()) { - adhocServerThread.join(); - } + adhocServerRunning = false; + if (adhocServerThread.joinable()) { + adhocServerThread.join(); } + // Checks to avoid confusing logspam if (netAdhocMatchingInited) { NetAdhocMatching_Term(); @@ -1180,8 +1179,8 @@ void __NetAdhocInit() { __AdhocServerInit(); // Create built-in AdhocServer Thread + adhocServerRunning = false; if (g_Config.bEnableWlan && g_Config.bEnableAdhocServer) { - adhocServerRunning = true; adhocServerThread = std::thread(proAdhocServerThread, SERVER_PORT); } }