Merge pull request #663 from nspcc-dev/fix-socket-leak
network: change the disconnect procedure
This commit is contained in:
commit
3fe7645e95
1 changed files with 2 additions and 2 deletions
|
@ -363,9 +363,9 @@ func (p *TCPPeer) PeerAddr() net.Addr {
|
||||||
// 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.finale.Do(func() {
|
p.finale.Do(func() {
|
||||||
p.server.unregister <- peerDrop{p, err}
|
|
||||||
p.conn.Close()
|
|
||||||
close(p.done)
|
close(p.done)
|
||||||
|
p.conn.Close()
|
||||||
|
p.server.unregister <- peerDrop{p, err}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue