From c6487423aefec8c3c4ee98ca5295cf38a931dfe7 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 13 Sep 2019 15:41:41 +0300 Subject: [PATCH] network: close connection on disconnect If it's already closed, this won't hurt, but in the case of logical error it saves us from leaking this connection (and potentially, peer). --- pkg/network/tcp_peer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/network/tcp_peer.go b/pkg/network/tcp_peer.go index e9e81ffa9..7703e7bd2 100644 --- a/pkg/network/tcp_peer.go +++ b/pkg/network/tcp_peer.go @@ -59,6 +59,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.conn.Close() p.done <- err }