Fix deadlock when reset occurs during cool-off period #17

Merged
dan merged 1 commits from fix-deadlock into master 2021-04-13 20:42:14 +00:00
2 changed files with 9 additions and 1 deletions

View File

@ -212,11 +212,12 @@ func (tp *torProvider) Restart() {
log.Debugf("launching restart...")
tp.lock.Lock()
defer tp.lock.Unlock()
log.Debugf("checking last restart time")
if time.Now().Sub(tp.lastRestartTime) < restartCooldown {
return
}
tp.lock.Unlock()
go tp.restart()
}

View File

@ -40,5 +40,12 @@ func TestTorProvider(t *testing.T) {
t.Logf("progress: %v", progress)
}
// Should skip without blocking...
acn.Restart()
acn.Restart()
acn.Restart()
acn.Close()
}