Skip to content

Commit

Permalink
p2p/enode prevent data race in sliceIter
Browse files Browse the repository at this point in the history
Node() had a data race with Next()
  • Loading branch information
MariusVanDerWijden committed Dec 3, 2019
1 parent 7ce7c39 commit 7d12adc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions p2p/enode/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (it *sliceIter) Next() bool {
}

func (it *sliceIter) Node() *Node {
it.mu.Lock()
defer it.mu.Unlock()
if len(it.nodes) == 0 {
return nil
}
Expand Down

0 comments on commit 7d12adc

Please sign in to comment.