Skip to content

Commit

Permalink
Merge pull request #1592 from nspcc-dev/dont-reconnect-if-pool-is-con…
Browse files Browse the repository at this point in the history
…nected

network: drop requests to discovery pool when it can't be handled
  • Loading branch information
roman-khimov authored Dec 7, 2020
2 parents c6dbddd + 1526772 commit fb13aca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/network/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,22 @@ func (d *DefaultDiscovery) run() {
requested--
}
default: // Empty pool
var added int
d.lock.Lock()
for _, addr := range d.seeds {
if !d.connectedAddrs[addr] {
delete(d.badAddrs, addr)
d.unconnectedAddrs[addr] = connRetries
d.pushToPoolOrDrop(addr)
added++
}
}
d.lock.Unlock()
// The pool is empty, but all seed nodes are already connected,
// we can end up in an infinite loop here, so drop the request.
if added == 0 {
requested = 0
}
}
}
if !ok {
Expand Down

0 comments on commit fb13aca

Please sign in to comment.