network: fix disconnection race between handleConn() and handleIncoming()

handleIncoming() winning the race for p.Disconnect() call might lead to nil
error passed as the reason for peer unregistration.
This commit is contained in:
Roman Khimov 2021-11-01 12:20:55 +03:00
parent 2eeec73770
commit 774dee3cd4

View file

@ -179,8 +179,8 @@ func (p *TCPPeer) handleConn() {
p.incoming <- msg
}
}
close(p.incoming)
p.Disconnect(err)
close(p.incoming)
}
func (p *TCPPeer) handleIncoming() {