mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-07-31 20:12:00 +00:00
fix a race in dial queue.
This commit is contained in:
@@ -208,9 +208,11 @@ func (dq *dialQueue) Consume() <-chan peer.ID {
|
||||
ch := make(chan peer.ID, 1)
|
||||
|
||||
select {
|
||||
case p := <-dq.out.DeqChan:
|
||||
// short circuit and return a dialled peer if it's immediately available.
|
||||
ch <- p
|
||||
case p, ok := <-dq.out.DeqChan:
|
||||
// short circuit and return a dialled peer if it's immediately available, or abort if DeqChan is closed.
|
||||
if ok {
|
||||
ch <- p
|
||||
}
|
||||
close(ch)
|
||||
return ch
|
||||
case <-dq.ctx.Done():
|
||||
|
Reference in New Issue
Block a user