forked from TrueCloudLab/neoneo-go
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:
parent
90e13debe4
commit
c6487423ae
1 changed files with 1 additions and 0 deletions
|
@ -59,6 +59,7 @@ func (p *TCPPeer) Done() chan error {
|
||||||
|
|
||||||
// Disconnect will fill the peer's done channel with the given error.
|
// Disconnect will fill the peer's done channel with the given error.
|
||||||
func (p *TCPPeer) Disconnect(err error) {
|
func (p *TCPPeer) Disconnect(err error) {
|
||||||
|
p.conn.Close()
|
||||||
p.done <- err
|
p.done <- err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue