server: improved performance and stability with broken AI and human games, e.g. less memory leaks and out of memory errors with AI (related to #11285, #5023);

This commit is contained in:
Oleg Agafonov 2025-06-29 00:59:31 +04:00
parent 5626079be9
commit dfb84b09f3
5 changed files with 14 additions and 17 deletions

View file

@ -897,7 +897,9 @@ public abstract class GameImpl implements Game {
numLosers++;
}
}
if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
boolean noMorePlayers = remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1;
// stop on no more players or on stopped game sim thread
if (noMorePlayers || Thread.currentThread().isInterrupted()) {
end();
if (remainingPlayers == 0 && logger.isDebugEnabled()) {
logger.debug("DRAW for gameId: " + getId());

View file

@ -2834,8 +2834,10 @@ public abstract class PlayerImpl implements Player, Serializable {
}
@Override
public boolean canRespond() { // abort is checked here to get out of player requests (as example: after disconnect)
return isInGame() && !abort;
public boolean canRespond() {
// abort is checked here to get out of player requests (as example: after disconnect)
// thread is checked here to get out of AI game simulations or close by third party tools
return isInGame() && !abort && !Thread.currentThread().isInterrupted();
}
@Override