From a2545d85dccfb889dd9db9df4a3b2df38f440138 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 10 Aug 2017 18:07:45 -0700 Subject: [PATCH] peer: ensure goroutine launched during initial handshake exits This commit fixes a bug which was covered by the recent server refactoring wherein the grouting would be stuck on the send over the message channel in the case that the handshake failed. This blockage would create a deadlock now that the ConnectToPeer method is full synchronous. We fix this issue by ensuring the goroutine properly exits. --- peer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/peer.go b/peer.go index 728ea02f..1e5ba284 100644 --- a/peer.go +++ b/peer.go @@ -216,6 +216,7 @@ func (p *peer) Start() error { if err != nil { readErr <- err msgChan <- nil + return } readErr <- nil msgChan <- msg