Skip to content

Commit

Permalink
fix handling of dead peers (#492)
Browse files Browse the repository at this point in the history
* fix handling of dead peers

* remove unnecessary continue
  • Loading branch information
vyzo committed Jul 1, 2022
1 parent 06b5ba4 commit 72562e6
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,16 @@ func (p *PubSub) handleDeadPeers() {
}

close(ch)
delete(p.peers, pid)

for t, tmap := range p.topics {
if _, ok := tmap[pid]; ok {
delete(tmap, pid)
p.notifyLeave(t, pid)
}
}

p.rt.RemovePeer(pid)

if p.host.Network().Connectedness(pid) == network.Connected {
backoffDelay, err := p.deadPeerBackoff.updateAndGet(pid)
Expand All @@ -708,20 +718,9 @@ func (p *PubSub) handleDeadPeers() {
log.Debugf("peer declared dead but still connected; respawning writer: %s", pid)
messages := make(chan *RPC, p.peerOutboundQueueSize)
messages <- p.getHelloPacket()
go p.handleNewPeerWithBackoff(p.ctx, pid, backoffDelay, messages)
p.peers[pid] = messages
continue
}

delete(p.peers, pid)
for t, tmap := range p.topics {
if _, ok := tmap[pid]; ok {
delete(tmap, pid)
p.notifyLeave(t, pid)
}
go p.handleNewPeerWithBackoff(p.ctx, pid, backoffDelay, messages)
}

p.rt.RemovePeer(pid)
}
}

Expand Down

0 comments on commit 72562e6

Please sign in to comment.