chainntnfs/btcdnotify: fix dropped block epoch notification bug
This commit a bug introduced in the chain notifier while we were limiting the usage of mutexes within the package. In a prior commit a default case was introduced in the select statement in order to avoid the possibility of the main goroutine blocking when dispatching block epoch notification. In order to avoid this potentially disastrous bug, we now instead launch a new goroutine for each client to ensure that all notifications are reliably dispatched.
This commit is contained in:
parent
d2b4f143b9
commit
608b9d96d1
@ -476,14 +476,13 @@ func (b *BtcdNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash.Hash
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, epochChan := range b.blockEpochClients {
|
for _, epochChan := range b.blockEpochClients {
|
||||||
// Attempt a non-blocking send. If the buffered channel is
|
go func(ntfnChan chan *chainntnfs.BlockEpoch) {
|
||||||
// full, then we no-op and move onto the next client.
|
|
||||||
select {
|
select {
|
||||||
case epochChan <- epoch:
|
case ntfnChan <- epoch:
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return
|
return
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
|
}(epochChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user