move the address invalidation check outside the lock
@@ -133,12 +133,11 @@ again:
ar.mx.Lock()
haveRelays := len(ar.relays)
if haveRelays >= DesiredRelays {
+ ar.mx.Unlock()
// this dance is necessary to cover the Private->Public->Private transition
// where we were already connected to enough relays while private and dropped
// the addrs while public
- needUpdate := ar.addrs == nil
- ar.mx.Unlock()
- if needUpdate {
+ if ar.addrs == nil {
ar.updateAddrs()
}
return
