Browse Source

fix selectLeastLoad() returns wrong number of nodes (#2083)

Jebbs 3 years ago
parent
commit
f9422d60aa
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/router/strategy_leastload.go

+ 2 - 2
app/router/strategy_leastload.go

@@ -118,8 +118,8 @@ func (l *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node {
 	// go through all base line until find expected selects
 	for _, b := range l.settings.Baselines {
 		baseline := time.Duration(b)
-		for i := 0; i < availableCount; i++ {
-			if nodes[i].RTTDeviationCost > baseline {
+		for i := count; i < availableCount; i++ {
+			if nodes[i].RTTDeviationCost >= baseline {
 				break
 			}
 			count = i + 1