mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-22 15:06:58 +00:00
Shut down computers on errors
Previously we would attempt to resume them, which then caused confusing behaviour if the Lua VM was in an inconsistent state. Closes #811
This commit is contained in:
parent
aa9d3c8269
commit
29cc5bb86b
@ -251,6 +251,20 @@ final class ComputerExecutor
|
|||||||
* and then schedule a shutdown.
|
* and then schedule a shutdown.
|
||||||
*/
|
*/
|
||||||
void abort()
|
void abort()
|
||||||
|
{
|
||||||
|
immediateFail( StateCommand.ABORT );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abort this whole computer due to an internal error. This will immediately destroy the Lua machine,
|
||||||
|
* and then schedule a shutdown.
|
||||||
|
*/
|
||||||
|
void fastFail()
|
||||||
|
{
|
||||||
|
immediateFail( StateCommand.ERROR );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void immediateFail( StateCommand command )
|
||||||
{
|
{
|
||||||
ILuaMachine machine = this.machine;
|
ILuaMachine machine = this.machine;
|
||||||
if( machine != null ) machine.close();
|
if( machine != null ) machine.close();
|
||||||
@ -258,7 +272,7 @@ final class ComputerExecutor
|
|||||||
synchronized( queueLock )
|
synchronized( queueLock )
|
||||||
{
|
{
|
||||||
if( closed ) return;
|
if( closed ) return;
|
||||||
command = StateCommand.ABORT;
|
this.command = command;
|
||||||
if( isOn ) enqueue();
|
if( isOn ) enqueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,6 +610,12 @@ final class ComputerExecutor
|
|||||||
displayFailure( "Error running computer", TimeoutState.ABORT_MESSAGE );
|
displayFailure( "Error running computer", TimeoutState.ABORT_MESSAGE );
|
||||||
shutdown();
|
shutdown();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ERROR:
|
||||||
|
if( !isOn ) return;
|
||||||
|
displayFailure( "Error running computer", "An internal error occurred, see logs." );
|
||||||
|
shutdown();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( event != null )
|
else if( event != null )
|
||||||
@ -644,6 +664,7 @@ final class ComputerExecutor
|
|||||||
SHUTDOWN,
|
SHUTDOWN,
|
||||||
REBOOT,
|
REBOOT,
|
||||||
ABORT,
|
ABORT,
|
||||||
|
ERROR,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Event
|
private static final class Event
|
||||||
|
@ -506,6 +506,8 @@ public final class ComputerThread
|
|||||||
catch( Exception | LinkageError | VirtualMachineError e )
|
catch( Exception | LinkageError | VirtualMachineError e )
|
||||||
{
|
{
|
||||||
ComputerCraft.log.error( "Error running task on computer #" + executor.getComputer().getID(), e );
|
ComputerCraft.log.error( "Error running task on computer #" + executor.getComputer().getID(), e );
|
||||||
|
// Tear down the computer immediately. There's no guarantee it's well behaved from now on.
|
||||||
|
executor.fastFail();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user