mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 04:56:36 +00:00
revert to using table parameter
using it.lookup.tab inside is unsafe Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
3589c0d59b
commit
de9fb9722b
1 changed files with 8 additions and 8 deletions
|
|
@ -189,7 +189,7 @@ func (it *lookupIterator) Next() bool {
|
||||||
if it.lookup.empty() {
|
if it.lookup.empty() {
|
||||||
// If the lookup is empty right after creation, it means the local table
|
// If the lookup is empty right after creation, it means the local table
|
||||||
// is in a degraded state, and we need to wait for it to fill again.
|
// is in a degraded state, and we need to wait for it to fill again.
|
||||||
it.lookupFailed(1 * time.Minute)
|
it.lookupFailed(it.lookup.tab, 1*time.Minute)
|
||||||
it.lookup = nil
|
it.lookup = nil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -209,30 +209,30 @@ func (it *lookupIterator) Next() bool {
|
||||||
|
|
||||||
// lookupFailed handles failed lookup attempts. This can be called when the table has
|
// lookupFailed handles failed lookup attempts. This can be called when the table has
|
||||||
// exited, or when it runs out of nodes.
|
// exited, or when it runs out of nodes.
|
||||||
func (it *lookupIterator) lookupFailed(timeout time.Duration) {
|
func (it *lookupIterator) lookupFailed(tab *Table, timeout time.Duration) {
|
||||||
ctx, cancel := context.WithTimeout(it.ctx, timeout)
|
tout, cancel := context.WithTimeout(it.ctx, timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Wait for Table initialization to complete, in case it is still in progress.
|
// Wait for Table initialization to complete, in case it is still in progress.
|
||||||
select {
|
select {
|
||||||
case <-it.lookup.tab.initDone:
|
case <-tab.initDone:
|
||||||
case <-ctx.Done():
|
case <-tout.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for ongoing refresh operation, or trigger one.
|
// Wait for ongoing refresh operation, or trigger one.
|
||||||
if it.tabRefreshing == nil {
|
if it.tabRefreshing == nil {
|
||||||
it.tabRefreshing = it.lookup.tab.refresh()
|
it.tabRefreshing = tab.refresh()
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-it.tabRefreshing:
|
case <-it.tabRefreshing:
|
||||||
it.tabRefreshing = nil
|
it.tabRefreshing = nil
|
||||||
case <-ctx.Done():
|
case <-tout.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the table to fill.
|
// Wait for the table to fill.
|
||||||
it.lookup.tab.waitForNodes(ctx, 1)
|
tab.waitForNodes(tout, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close ends the iterator.
|
// Close ends the iterator.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue