vms: Fix deadlock when stopping timers during spdagvm.VM.Shutdown()

refs #66
This commit is contained in:
Alex Willmer 2020-04-21 01:40:46 +01:00
parent 996ea99fb1
commit 2e02f6863e
1 changed files with 4 additions and 0 deletions

View File

@ -134,7 +134,11 @@ func (vm *VM) Shutdown() {
return
}
// There is a potential deadlock if the timer is about to execute a timeout.
// So, the lock must be released before stopping the timer.
vm.ctx.Lock.Unlock()
vm.timer.Stop()
vm.ctx.Lock.Lock()
if err := vm.baseDB.Close(); err != nil {
vm.ctx.Log.Error("Closing the database failed with %s", err)
}