Simplify server tick timeout handling.

This commit is contained in:
Paul Chote
2018-08-11 14:04:49 +01:00
parent d37119655b
commit efccd610d3
3 changed files with 4 additions and 9 deletions

View File

@@ -170,7 +170,6 @@ namespace OpenRA.Server
Log.Write("server", "Initial mod: {0}", ModData.Manifest.Id); Log.Write("server", "Initial mod: {0}", ModData.Manifest.Id);
Log.Write("server", "Initial map: {0}", LobbyInfo.GlobalSettings.Map); Log.Write("server", "Initial map: {0}", LobbyInfo.GlobalSettings.Map);
var timeout = serverTraits.WithInterface<ITick>().Min(t => t.TickTimeout);
for (;;) for (;;)
{ {
var checkRead = new List<Socket>(); var checkRead = new List<Socket>();
@@ -180,7 +179,9 @@ namespace OpenRA.Server
checkRead.AddRange(Conns.Select(c => c.Socket)); checkRead.AddRange(Conns.Select(c => c.Socket));
checkRead.AddRange(PreConns.Select(c => c.Socket)); checkRead.AddRange(PreConns.Select(c => c.Socket));
var localTimeout = waitingForAuthenticationCallback > 0 ? 100000 : timeout; // Block for at most 1 second in order to guarantee a minimum tick rate for ServerTraits
// Decrease this to 100ms to improve responsiveness if we are waiting for an authentication query
var localTimeout = waitingForAuthenticationCallback > 0 ? 100000 : 1000000;
if (checkRead.Count > 0) if (checkRead.Count > 0)
Socket.Select(checkRead, null, null, localTimeout); Socket.Select(checkRead, null, null, localTimeout);

View File

@@ -23,11 +23,7 @@ namespace OpenRA.Server
public interface IStartGame { void GameStarted(Server server); } public interface IStartGame { void GameStarted(Server server); }
public interface IClientJoined { void ClientJoined(Server server, Connection conn); } public interface IClientJoined { void ClientJoined(Server server, Connection conn); }
public interface IEndGame { void GameEnded(Server server); } public interface IEndGame { void GameEnded(Server server); }
public interface ITick public interface ITick { void Tick(Server server); }
{
void Tick(Server server);
int TickTimeout { get; }
}
public abstract class ServerTrait { } public abstract class ServerTrait { }

View File

@@ -33,8 +33,6 @@ namespace OpenRA.Mods.Common.Server
{ 2, "Server name contains a blacklisted word." } { 2, "Server name contains a blacklisted word." }
}; };
public int TickTimeout { get { return MasterPingInterval * 10000; } }
long lastPing = 0; long lastPing = 0;
bool isInitialPing = true; bool isInitialPing = true;