Fix deadlock when reset occurs during cool-off period
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2021-04-13 13:39:33 -07:00
parent fd0cf2f7a2
commit a40c4b9e1d
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()
}