If plugins or Torch call the static ctor of MyEntities too early the game doesn't break.

Freeze isn't fatal when compiled with DEBUG.  (So you can use breakpoints)
This commit is contained in:
Westin Miller
2017-10-31 20:55:48 -07:00
parent c8f42e8a48
commit 0558675132
5 changed files with 143 additions and 78 deletions

View File

@@ -203,11 +203,18 @@ namespace Torch.Server
((TorchServer)state).Invoke(() => mre.Set());
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
{
#if DEBUG
Log.Error($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.");
Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread));
#else
Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread));
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.");
#endif
}
else
{
Log.Debug("Server watchdog responded");
}
Log.Debug("Server watchdog responded");
}
private static string DumpFrozenThread(Thread thread, int traces = 3, int pause = 5000)