Fix MessageBox spam if Torch crashes with UI enabled and autorestart disabled

This commit is contained in:
John Gross
2019-09-13 11:46:35 -07:00
parent d661c893d5
commit 79368aa6dd
2 changed files with 10 additions and 1 deletions

View File

@@ -245,6 +245,7 @@ quit";
private void HandleException(object sender, UnhandledExceptionEventArgs e)
{
_server.FatalException = true;
var ex = (Exception)e.ExceptionObject;
LogException(ex);
if (MyFakes.ENABLE_MINIDUMP_SENDING)

View File

@@ -49,6 +49,8 @@ namespace Torch.Server
private Timer _watchdog;
private int _players;
private MultiplayerManagerDedicated _multiplayerManagerDedicated;
internal bool FatalException { get; set; }
/// <inheritdoc />
public TorchServer(TorchConfig config = null)
@@ -232,10 +234,16 @@ namespace Torch.Server
private static void CheckServerResponding(object state)
{
var server = (TorchServer)state;
var mre = new ManualResetEvent(false);
((TorchServer)state).Invoke(() => mre.Set());
server.Invoke(() => mre.Set());
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
{
if (server.FatalException)
{
server._watchdog.Dispose();
return;
}
#if DEBUG
Log.Error(
$"Server watchdog detected that the server was frozen for at least {((TorchServer) state).Config.TickTimeout} seconds.");