mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
Correct issue with pushing address messages.
The code to send an address messages in batches was previously clearing all addresses from the existing message after queueing it to be sent. Since the message is a pointer, this means it was removing the addresses from the same message which might not have already been sent yet (from another goroutine) which led to a race. This commit modifies the code to create a new address message for each batch as intended. Fixes #58.
This commit is contained in:
parent
9e44506fdc
commit
c8e88d383e
6
peer.go
6
peer.go
@ -773,7 +773,11 @@ func (p *peer) pushAddrMsg(addresses []*btcwire.NetAddress) error {
|
||||
// Split into multiple messages as needed.
|
||||
if numAdded > 0 && numAdded%btcwire.MaxAddrPerMsg == 0 {
|
||||
p.QueueMessage(msg, nil)
|
||||
msg.ClearAddresses()
|
||||
|
||||
// NOTE: This needs to be a new address message and not
|
||||
// simply call ClearAddresses since the message is a
|
||||
// pointer and queueing it does not make a copy.
|
||||
msg = btcwire.NewMsgAddr()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user