peer: disconnected peer - return non-nil LocalAddr

This commit is contained in:
Javed Khan 2016-11-15 00:14:26 +05:30 committed by Dave Collins
parent b134beb3b7
commit 7f237aa5e5

View file

@ -686,7 +686,7 @@ func (p *Peer) LastRecv() time.Time {
// This function is safe fo concurrent access.
func (p *Peer) LocalAddr() net.Addr {
var localAddr net.Addr
if p.Connected() {
if atomic.LoadInt32(&p.connected) != 0 {
localAddr = p.conn.LocalAddr()
}
return localAddr