From 0c69da940943bdacd51507bd8b49e81233329dc5 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sun, 14 Apr 2019 17:50:22 +0300 Subject: [PATCH] move the address invalidation check outside the lock --- p2p/host/relay/autorelay.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/p2p/host/relay/autorelay.go b/p2p/host/relay/autorelay.go index 842f2ea68..c3edbad88 100644 --- a/p2p/host/relay/autorelay.go +++ b/p2p/host/relay/autorelay.go @@ -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