Merge pull request #663 from nspcc-dev/fix-socket-leak

network: change the disconnect procedure
This commit is contained in:
Roman Khimov 2020-02-13 16:55:47 +03:00 committed by GitHub
commit 3fe7645e95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -363,9 +363,9 @@ func (p *TCPPeer) PeerAddr() net.Addr {
// Disconnect will fill the peer's done channel with the given error.
func (p *TCPPeer) Disconnect(err error) {
p.finale.Do(func() {
p.server.unregister <- peerDrop{p, err}
p.conn.Close()
close(p.done)
p.conn.Close()
p.server.unregister <- peerDrop{p, err}
})
}