@@ -189,7 +189,7 @@ func (it *lookupIterator) Next() bool {
189
189
if it .lookup .empty () {
190
190
// If the lookup is empty right after creation, it means the local table
191
191
// is in a degraded state, and we need to wait for it to fill again.
192
- it .lookupFailed (1 * time .Minute )
192
+ it .lookupFailed (it . lookup . tab , 1 * time .Minute )
193
193
it .lookup = nil
194
194
continue
195
195
}
@@ -209,30 +209,30 @@ func (it *lookupIterator) Next() bool {
209
209
210
210
// lookupFailed handles failed lookup attempts. This can be called when the table has
211
211
// exited, or when it runs out of nodes.
212
- func (it * lookupIterator ) lookupFailed (timeout time.Duration ) {
213
- ctx , cancel := context .WithTimeout (it .ctx , timeout )
212
+ func (it * lookupIterator ) lookupFailed (tab * Table , timeout time.Duration ) {
213
+ tout , cancel := context .WithTimeout (it .ctx , timeout )
214
214
defer cancel ()
215
215
216
216
// Wait for Table initialization to complete, in case it is still in progress.
217
217
select {
218
- case <- it . lookup . tab .initDone :
219
- case <- ctx .Done ():
218
+ case <- tab .initDone :
219
+ case <- tout .Done ():
220
220
return
221
221
}
222
222
223
223
// Wait for ongoing refresh operation, or trigger one.
224
224
if it .tabRefreshing == nil {
225
- it .tabRefreshing = it . lookup . tab .refresh ()
225
+ it .tabRefreshing = tab .refresh ()
226
226
}
227
227
select {
228
228
case <- it .tabRefreshing :
229
229
it .tabRefreshing = nil
230
- case <- ctx .Done ():
230
+ case <- tout .Done ():
231
231
return
232
232
}
233
233
234
234
// Wait for the table to fill.
235
- it . lookup . tab .waitForNodes (ctx , 1 )
235
+ tab .waitForNodes (tout , 1 )
236
236
}
237
237
238
238
// Close ends the iterator.
0 commit comments