From c183e8984c038bafa827746d7ef94193a229319a Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 3 Aug 2017 13:52:02 -0700 Subject: [PATCH] peer: properly clean up chanMsgStreams map on readHandler exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit ensures that all references within the chanMsgStreams are all removed and deleted when the readHandler exits. This ensures that all objects don’t have extra references, and will properly be garbage collected. --- peer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index d83f7c37..e4790f00 100644 --- a/peer.go +++ b/peer.go @@ -645,8 +645,10 @@ out: p.Disconnect(errors.New("read handler closed")) - for _, chanStream := range chanMsgStreams { + for cid, chanStream := range chanMsgStreams { chanStream.Stop() + + delete(chanMsgStreams, cid) } p.wg.Done()