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).
This commit is contained in:
Roman Khimov 2019-09-13 15:41:41 +03:00
parent 90e13debe4
commit c6487423ae

View file

@ -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
}