mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	plugin/loadbalance: More consistent shuffling (#4961)
* fix shuffling Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * shuffle each record once Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
		| @@ -61,13 +61,12 @@ func roundRobinShuffle(records []dns.RR) { | |||||||
| 			records[0], records[1] = records[1], records[0] | 			records[0], records[1] = records[1], records[0] | ||||||
| 		} | 		} | ||||||
| 	default: | 	default: | ||||||
| 		for j := 0; j < l*(int(dns.Id())%4+1); j++ { | 		for j := 0; j < l; j++ { | ||||||
| 			q := int(dns.Id()) % l | 			p := j + (int(dns.Id()) % (l-j)) | ||||||
| 			p := int(dns.Id()) % l | 			if j == p { | ||||||
| 			if q == p { | 				continue | ||||||
| 				p = (p + 1) % l |  | ||||||
| 			} | 			} | ||||||
| 			records[q], records[p] = records[p], records[q] | 			records[j], records[p] = records[p], records[j] | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user