Fix deadlock when reset occurs during cool-off period
This commit is contained in:
parent
fd0cf2f7a2
commit
a40c4b9e1d
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue