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

This commit is contained in:
Felföldi Zsolt 2022-03-01 10:36:42 +01:00 committed by GitHub
parent 03b7de28b2
commit 7033724522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -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