Skip to content

Commit

Permalink
fix race for hasPeerCh pointer read
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss committed Oct 10, 2023
1 parent 00b32a8 commit be29fb7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion share/p2p/peers/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ func (p *pool) next(ctx context.Context) <-chan peer.ID {
return
}

p.m.RLock()
hasPeerCh := p.hasPeerCh
p.m.RUnlock()
select {
case <-p.hasPeerCh:
case <-hasPeerCh:
case <-ctx.Done():
return
}
Expand Down

0 comments on commit be29fb7

Please sign in to comment.