Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRITICAL: NetworkPlayers.DropPlayers function leaks Players sessions. #17

Open
GitHubProUser67 opened this issue May 18, 2024 · 0 comments

Comments

@GitHubProUser67
Copy link

The function: NetworkPlayers.DropPlayers has a bug where player sessions are being leaked in memory over time due to silent failing.

On my fork, I solved the issue by locking a removal instance like this:

private static object lockObject = new();

public static void DropPlayers()
{
lock (lockObject) // Prevents the same action being done multiple times if the loop is very tight.
{
Players.RemoveAll(playerInfo => {
if (playerInfo.Client?.State != QClient.StateType.Dropped)
return false;
if (playerInfo.Client.TimeSinceLastPacket < Constants.ClientTimeoutSeconds)
return false;
LoggerAccessor.LogWarn($"[Quazal NetworkPlayers] - auto-dropping player: {playerInfo.Name}");
if (playerInfo.Client != null)
playerInfo.Client.PlayerInfo = null;
playerInfo.OnDropped();
return true;
});
}
}

This bug will prevent ghost players being returned as game start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant