server: Fix persistent peers not being removed properly
When a persistent peer is disconnected (for example due to a network timeout), a connection retry is issued. The logic for doing so failed to remove the peer from the peerState, causing dead peer connections to fill the peerState. Since connections in the peerState are counted towards the maxPeers limit, this would cause btcd to eventually stop retrying connection. This commit fixes the issue by properly removing the peer from the peerState.
This commit is contained in:
parent
89af747603
commit
d0cdd53720
1 changed files with 3 additions and 5 deletions
|
@ -1124,12 +1124,10 @@ func (s *server) handleDonePeerMsg(state *peerState, sp *serverPeer) {
|
||||||
// persistent outbound connection.
|
// persistent outbound connection.
|
||||||
if !sp.Inbound() && sp.persistent && atomic.LoadInt32(&s.shutdown) == 0 {
|
if !sp.Inbound() && sp.persistent && atomic.LoadInt32(&s.shutdown) == 0 {
|
||||||
// Retry peer
|
// Retry peer
|
||||||
sp = s.newOutboundPeer(sp.Addr(), sp.persistent)
|
sp2 := s.newOutboundPeer(sp.Addr(), sp.persistent)
|
||||||
if sp != nil {
|
if sp2 != nil {
|
||||||
go s.retryConn(sp, false)
|
go s.retryConn(sp2, false)
|
||||||
}
|
}
|
||||||
list[sp.ID()] = sp
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if !sp.Inbound() && sp.VersionKnown() {
|
if !sp.Inbound() && sp.VersionKnown() {
|
||||||
state.outboundGroups[addrmgr.GroupKey(sp.NA())]--
|
state.outboundGroups[addrmgr.GroupKey(sp.NA())]--
|
||||||
|
|
Loading…
Reference in a new issue