Merge pull request #80 from TorchAPI/shutdown-crash-fix
Check if thread is running before suspending
This commit is contained in:
@@ -30,6 +30,7 @@ using VRage.Library;
|
|||||||
using VRage.ObjectBuilders;
|
using VRage.ObjectBuilders;
|
||||||
using VRage.Plugins;
|
using VRage.Plugins;
|
||||||
using VRage.Utils;
|
using VRage.Utils;
|
||||||
|
|
||||||
#pragma warning disable 618
|
#pragma warning disable 618
|
||||||
|
|
||||||
namespace Torch.Server
|
namespace Torch.Server
|
||||||
@@ -182,7 +183,8 @@ namespace Torch.Server
|
|||||||
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
|
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
|
||||||
{
|
{
|
||||||
var mainThread = MySandboxGame.Static.UpdateThread;
|
var mainThread = MySandboxGame.Static.UpdateThread;
|
||||||
mainThread.Suspend();
|
if (mainThread.IsAlive)
|
||||||
|
mainThread.Suspend();
|
||||||
var stackTrace = new StackTrace(mainThread, true);
|
var stackTrace = new StackTrace(mainThread, true);
|
||||||
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.\n{stackTrace}");
|
throw new TimeoutException($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds.\n{stackTrace}");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user