fixed shardSessions locks

This commit is contained in:
Kamil
2020-12-17 10:28:44 +01:00
parent 236aff1dcb
commit 619e3a70b3

View File

@@ -568,8 +568,10 @@ bool CNLoginServer::isAccountInUse(int accountId) {
return true; return true;
} }
// check shard server connections // check shard server connections
std::lock_guard<std::mutex> lock(lsCrit); lsCrit.lock();
return (shardSessions.find(accountId) != shardSessions.end()); bool result = shardSessions.find(accountId) != shardSessions.end();
lsCrit.unlock();
return(result);
} }
void CNLoginServer::exitDuplicate(int accountId) { void CNLoginServer::exitDuplicate(int accountId) {
@@ -585,8 +587,10 @@ void CNLoginServer::exitDuplicate(int accountId) {
} }
} }
// shard server // shard server
std::lock_guard<std::mutex> lock(lsCrit); lsCrit.lock();
if (shardSessions.find(accountId) == shardSessions.end()) bool found = shardSessions.find(accountId) != shardSessions.end();
lsCrit.unlock();
if (!found)
return; return;
CNSocket* sock = shardSessions[accountId]; CNSocket* sock = shardSessions[accountId];
PlayerManager::exitDuplicate(sock); PlayerManager::exitDuplicate(sock);