From a7656454aab52f7dd3be001d41cf335f4208da87 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 24 Aug 2018 17:53:07 -0700 Subject: [PATCH] peer: stop chanMsg streams in defer right after creation --- peer.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/peer.go b/peer.go index 7c979f85..63566a8e 100644 --- a/peer.go +++ b/peer.go @@ -1057,6 +1057,7 @@ out: chanStream = newChanMsgStream(p, targetChan) chanMsgStreams[targetChan] = chanStream chanStream.Start() + defer chanStream.Stop() } // With the stream obtained, add the message to the @@ -1069,12 +1070,6 @@ out: p.Disconnect(errors.New("read handler closed")) - for cid, chanStream := range chanMsgStreams { - chanStream.Stop() - - delete(chanMsgStreams, cid) - } - peerLog.Tracef("readHandler for peer %v done", p) }