From f39d5d5a1077f1f9edee352655b04e54841f3e7e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 15 Jan 2020 17:08:08 +0300 Subject: [PATCH] network: fix unregistration on peer Disconnect It should always signal to the server, not duplicating this send and not missing it like it happened in the Server.run(). --- pkg/network/tcp_peer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/network/tcp_peer.go b/pkg/network/tcp_peer.go index 54cb6c1ec..bbd22b51b 100644 --- a/pkg/network/tcp_peer.go +++ b/pkg/network/tcp_peer.go @@ -109,7 +109,6 @@ func (p *TCPPeer) handleConn() { } } } - p.server.unregister <- peerDrop{p, err} p.Disconnect(err) } @@ -171,7 +170,6 @@ func (p *TCPPeer) StartProtocol() { } } if err != nil { - p.server.unregister <- peerDrop{p, err} timer.Stop() p.Disconnect(err) return @@ -284,6 +282,7 @@ func (p *TCPPeer) Done() chan error { // Disconnect will fill the peer's done channel with the given error. func (p *TCPPeer) Disconnect(err error) { + p.server.unregister <- peerDrop{p, err} p.conn.Close() select { case p.done <- err: