Merge pull request 'Fix deadlock when reset occurs during cool-off period' (#17) from fix-deadlock into master
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

Reviewed-on: #17
This commit is contained in:
Dan Ballard 2021-04-13 13:42:13 -07:00
commit 9947d289c7
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()
}