mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix threading issue when exiting PPSSPP due to unjoined AdhocServer thread when AdhocServer failed to bind the socket and exited the thread early.
This commit is contained in:
parent
1fd54153fc
commit
6a79f59c06
4 changed files with 8 additions and 9 deletions
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include "Common/Net/Resolve.h"
|
#include "Common/Net/Resolve.h"
|
||||||
#include "Common/Serialize/Serializer.h"
|
#include "Common/Serialize/Serializer.h"
|
||||||
|
|
|
@ -80,8 +80,7 @@ SceNetAdhocctlUserNode * _db_user = NULL;
|
||||||
SceNetAdhocctlGameNode * _db_game = NULL;
|
SceNetAdhocctlGameNode * _db_game = NULL;
|
||||||
|
|
||||||
// Server Status
|
// Server Status
|
||||||
//int _status = 0;
|
std::atomic<bool> adhocServerRunning(false);
|
||||||
bool adhocServerRunning = false;
|
|
||||||
std::thread adhocServerThread;
|
std::thread adhocServerThread;
|
||||||
|
|
||||||
// Crosslink database for cross region Adhoc play
|
// Crosslink database for cross region Adhoc play
|
||||||
|
|
|
@ -369,5 +369,5 @@ void update_status();
|
||||||
int proAdhocServerThread(int port); // (int argc, char * argv[])
|
int proAdhocServerThread(int port); // (int argc, char * argv[])
|
||||||
|
|
||||||
//extern int _status;
|
//extern int _status;
|
||||||
extern bool adhocServerRunning;
|
extern std::atomic<bool> adhocServerRunning;
|
||||||
extern std::thread adhocServerThread;
|
extern std::thread adhocServerThread;
|
||||||
|
|
|
@ -118,12 +118,11 @@ static int sceNetAdhocPdpRecv(int id, void* addr, void* port, void* buf, void* d
|
||||||
|
|
||||||
void __NetAdhocShutdown() {
|
void __NetAdhocShutdown() {
|
||||||
// Kill AdhocServer Thread
|
// Kill AdhocServer Thread
|
||||||
if (adhocServerRunning) {
|
adhocServerRunning = false;
|
||||||
adhocServerRunning = false;
|
if (adhocServerThread.joinable()) {
|
||||||
if (adhocServerThread.joinable()) {
|
adhocServerThread.join();
|
||||||
adhocServerThread.join();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks to avoid confusing logspam
|
// Checks to avoid confusing logspam
|
||||||
if (netAdhocMatchingInited) {
|
if (netAdhocMatchingInited) {
|
||||||
NetAdhocMatching_Term();
|
NetAdhocMatching_Term();
|
||||||
|
@ -1180,8 +1179,8 @@ void __NetAdhocInit() {
|
||||||
__AdhocServerInit();
|
__AdhocServerInit();
|
||||||
|
|
||||||
// Create built-in AdhocServer Thread
|
// Create built-in AdhocServer Thread
|
||||||
|
adhocServerRunning = false;
|
||||||
if (g_Config.bEnableWlan && g_Config.bEnableAdhocServer) {
|
if (g_Config.bEnableWlan && g_Config.bEnableAdhocServer) {
|
||||||
adhocServerRunning = true;
|
|
||||||
adhocServerThread = std::thread(proAdhocServerThread, SERVER_PORT);
|
adhocServerThread = std::thread(proAdhocServerThread, SERVER_PORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue