forked from TrueCloudLab/neoneo-go
network: don't deadlock on connection overflow
(*Peer).Disconnect send an unregister signal to this goroutine, so invoking it from here is not a good idea, run it asynchronously.
This commit is contained in:
parent
cad1f074d4
commit
e2116e4c3f
1 changed files with 2 additions and 1 deletions
|
@ -226,7 +226,8 @@ func (s *Server) run() {
|
||||||
s.lock.RLock()
|
s.lock.RLock()
|
||||||
// Pick a random peer and drop connection to it.
|
// Pick a random peer and drop connection to it.
|
||||||
for peer := range s.peers {
|
for peer := range s.peers {
|
||||||
peer.Disconnect(errMaxPeers)
|
// It will send us unregister signal.
|
||||||
|
go peer.Disconnect(errMaxPeers)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
s.lock.RUnlock()
|
s.lock.RUnlock()
|
||||||
|
|
Loading…
Reference in a new issue