|
@@ -87,12 +87,13 @@ func (r *roundRobinHostPolicy) Pick(qry *Query) NextHost {
|
|
|
// to the number of hosts known to this policy
|
|
// to the number of hosts known to this policy
|
|
|
var i uint32 = 0
|
|
var i uint32 = 0
|
|
|
return func() *HostInfo {
|
|
return func() *HostInfo {
|
|
|
|
|
+ r.mu.RLock()
|
|
|
if len(r.hosts) == 0 {
|
|
if len(r.hosts) == 0 {
|
|
|
|
|
+ r.mu.RUnlock()
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var host *HostInfo
|
|
var host *HostInfo
|
|
|
- r.mu.RLock()
|
|
|
|
|
// always increment pos to evenly distribute traffic in case of
|
|
// always increment pos to evenly distribute traffic in case of
|
|
|
// failures
|
|
// failures
|
|
|
pos := atomic.AddUint32(&r.pos, 1)
|
|
pos := atomic.AddUint32(&r.pos, 1)
|