Skip to content

Commit

Permalink
Fix #50 server crash
Browse files Browse the repository at this point in the history
World::Players was accessed in a non-thread-safe way from the player saving thread.
  • Loading branch information
vilarion committed Dec 3, 2020
1 parent b91fc82 commit e6f9437
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/PlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ void PlayerManager::playerSaveLoop(PlayerManager *pmanager) {
std::lock_guard<std::mutex> lock(mut);
pmanager->loggedOutPlayers.pop_front();
}

Logger::debug(LogFacility::World) << "update player list [begin]" << Log::end;
world->updatePlayerList();
Logger::debug(LogFacility::World) << "update player list [end]" << Log::end;
}

using namespace std::chrono_literals;
Expand Down
4 changes: 4 additions & 0 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ void World::checkPlayers() {
for (const auto &player : lostPlayers) {
Players.erase(player->getId());
}

if (!lostPlayers.empty()) {
updatePlayerList();
}
}

void World::checkPlayerImmediateCommands() {
Expand Down

0 comments on commit e6f9437

Please sign in to comment.