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) private void HandleException(object sender, UnhandledExceptionEventArgs e)
{ {
_server.FatalException = true;
var ex = (Exception)e.ExceptionObject; var ex = (Exception)e.ExceptionObject;
LogException(ex); LogException(ex);
if (MyFakes.ENABLE_MINIDUMP_SENDING) if (MyFakes.ENABLE_MINIDUMP_SENDING)

View File

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