wtclient: make addr iterator panic safe
Ensure that calling Next twice in a row without first calling Reset is safe when the iterator is at the end of its list. Also alter the towerListIterator to call Reset after hitting an error on Next.
This commit is contained in:
3 files changed
+6
-7
No files matched your search
@@ -162,6 +162,10 @@ func (a *addressIterator) next(lock bool) (net.Addr, error) {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
|
||||
if a.currentTopAddr == nil {
|
||||
return nil, ErrAddressesExhausted
|
||||
}
|
||||
|
||||
// Set the next candidate to the subsequent element.
|
||||
a.currentTopAddr = a.currentTopAddr.Next()
|
||||
|
||||
|
||||
Reference in new issue
Block a user