mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Should fix potential deadlock when machines get disposed while they're running. Closes #1322.
This commit is contained in:
parent
284598d9a2
commit
00da2ee53e
@ -835,9 +835,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
private def close() = state.synchronized(
|
private def close() =
|
||||||
if (state.isEmpty || state.top != Machine.State.Stopped) {
|
if (state.synchronized(state.isEmpty || state.top != Machine.State.Stopped)) {
|
||||||
this.synchronized {
|
// Give up the state lock, then get the more generic lock on this instance first
|
||||||
|
// before locking on state again. Always must be in that order to avoid deadlocks.
|
||||||
|
this.synchronized(state.synchronized {
|
||||||
state.clear()
|
state.clear()
|
||||||
state.push(Machine.State.Stopped)
|
state.push(Machine.State.Stopped)
|
||||||
Option(architecture).foreach(_.close())
|
Option(architecture).foreach(_.close())
|
||||||
@ -846,11 +848,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
cpuTotal = 0
|
cpuTotal = 0
|
||||||
cpuStart = 0
|
cpuStart = 0
|
||||||
remainIdle = 0
|
remainIdle = 0
|
||||||
}
|
})
|
||||||
|
|
||||||
// Mark state change in owner, to send it to clients.
|
// Mark state change in owner, to send it to clients.
|
||||||
host.markChanged()
|
host.markChanged()
|
||||||
})
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user