diff --git a/tor/torProvider.go b/tor/torProvider.go index 6819a1f..2bce6d5 100644 --- a/tor/torProvider.go +++ b/tor/torProvider.go @@ -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() } diff --git a/tor/torProvider_test.go b/tor/torProvider_test.go index d906c3d..dcb0e5d 100644 --- a/tor/torProvider_test.go +++ b/tor/torProvider_test.go @@ -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() }