Skip to content

Commit

Permalink
les/vflux/client: fix goroutine leak in testIter (#24449)
Browse files Browse the repository at this point in the history
  • Loading branch information
zsfelfoldi authored and qinglin89 committed Aug 18, 2022
1 parent 62d66e4 commit e5f4fde
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions les/vflux/client/fillset_test.go
Expand Up @@ -34,16 +34,20 @@ type testIter struct {
}

func (i *testIter) Next() bool {
i.waitCh <- struct{}{}
if _, ok := <-i.waitCh; !ok {
return false
}
i.node = <-i.nodeCh
return i.node != nil
return true
}

func (i *testIter) Node() *enode.Node {
return i.node
}

func (i *testIter) Close() {}
func (i *testIter) Close() {
close(i.waitCh)
}

func (i *testIter) push() {
var id enode.ID
Expand All @@ -53,7 +57,7 @@ func (i *testIter) push() {

func (i *testIter) waiting(timeout time.Duration) bool {
select {
case <-i.waitCh:
case i.waitCh <- struct{}{}:
return true
case <-time.After(timeout):
return false
Expand Down

0 comments on commit e5f4fde

Please sign in to comment.