From f82af595dcf5042de2e738a974d28b3035581cf5 Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 13 Dec 2018 23:45:30 +0200 Subject: [PATCH] don't share the outgoing channel in new stream handlers from disconnects --- pubsub.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pubsub.go b/pubsub.go index cc0ce3f..aeb076a 100644 --- a/pubsub.go +++ b/pubsub.go @@ -316,15 +316,18 @@ func (p *PubSub) processLoop(ctx context.Context) { continue } + close(ch) + if p.host.Network().Connectedness(pid) == inet.Connected { // still connected, must be a duplicate connection being closed. // we respawn the writer as we need to ensure there is a stream active log.Warning("peer declared dead but still connected; respawning writer: ", pid) - go p.handleNewPeer(ctx, pid, ch) + messages := make(chan *RPC, 32) + go p.handleNewPeer(ctx, pid, messages) + p.peers[pid] = messages continue } - close(ch) delete(p.peers, pid) for _, t := range p.topics { delete(t, pid)