Merge pull request #7238 from Mailaender/server-cpu-fix

Fixed high CPU usage due to Socket.Select not blocking the thread properly when the game started
This commit is contained in:
Matthias Mailänder
2015-01-01 10:53:40 +01:00
2 changed files with 3 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ Also thanks to:
* Andrew Perkins
* Andrew Riedi
* Andreas Beck (baxtor)
* Ang Soon Li (asl97)
* Arik Lirette (Angusm3)
* Barnaby Smith (mvi)
* Bellator

View File

@@ -156,11 +156,11 @@ namespace OpenRA.Server
for (;;)
{
var checkRead = new List<Socket>();
checkRead.Add(listener.Server);
if (State == ServerState.WaitingPlayers) checkRead.Add(listener.Server);
foreach (var c in Conns) checkRead.Add(c.socket);
foreach (var c in PreConns) checkRead.Add(c.socket);
Socket.Select(checkRead, null, null, timeout);
if (checkRead.Count > 0) Socket.Select(checkRead, null, null, timeout);
if (State == ServerState.ShuttingDown)
{
EndGame();