Unverified Commit 70337245 authored by Felföldi Zsolt's avatar Felföldi Zsolt Committed by GitHub

les/vflux/client: fix goroutine leak in testIter (#24449)

parent 03b7de28
...@@ -34,16 +34,20 @@ type testIter struct { ...@@ -34,16 +34,20 @@ type testIter struct {
} }
func (i *testIter) Next() bool { func (i *testIter) Next() bool {
i.waitCh <- struct{}{} if _, ok := <-i.waitCh; !ok {
return false
}
i.node = <-i.nodeCh i.node = <-i.nodeCh
return i.node != nil return true
} }
func (i *testIter) Node() *enode.Node { func (i *testIter) Node() *enode.Node {
return i.node return i.node
} }
func (i *testIter) Close() {} func (i *testIter) Close() {
close(i.waitCh)
}
func (i *testIter) push() { func (i *testIter) push() {
var id enode.ID var id enode.ID
...@@ -53,7 +57,7 @@ func (i *testIter) push() { ...@@ -53,7 +57,7 @@ func (i *testIter) push() {
func (i *testIter) waiting(timeout time.Duration) bool { func (i *testIter) waiting(timeout time.Duration) bool {
select { select {
case <-i.waitCh: case i.waitCh <- struct{}{}:
return true return true
case <-time.After(timeout): case <-time.After(timeout):
return false return false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment