mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 23:12:31 +00:00
Fix a race in the amgr found by the race detector.
This commit is contained in:
parent
6f063e0c1b
commit
bc6ff038e3
@ -140,7 +140,11 @@ func (a *AddrManager) updateAddress(netAddr, srcAddr *btcwire.NetAddress) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ka = &knownAddress{na: netAddr, srcAddr: srcAddr}
|
// Make a copy of the net address to avoid races since it is
|
||||||
|
// updated elsewhere in the addrmanager code and would otherwise
|
||||||
|
// change the actual netaddress on the peer.
|
||||||
|
netAddrCopy := *netAddr
|
||||||
|
ka = &knownAddress{na: &netAddrCopy, srcAddr: srcAddr}
|
||||||
a.addrIndex[addr] = ka
|
a.addrIndex[addr] = ka
|
||||||
a.nNew++
|
a.nNew++
|
||||||
// XXX time penalty?
|
// XXX time penalty?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user