Skip to content

Commit 77b3c65

Browse files
committed
Minor change to LBStrategyPH.getActiveCount()
Special case: 2 servers, 1 is dead, and estimatorUpdate is skipped. Count Before After 1 1 1 2 2 1 3 2 2 4 2 2 5 2 3 6 3 3 7 3 4
1 parent 4457dd5 commit 77b3c65

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

dnscrypt-proxy/serversInfo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ func (s LBStrategyPN) getActiveCount(serversCount int) int {
9898
type LBStrategyPH struct{}
9999

100100
func (LBStrategyPH) getCandidate(serversCount int) int {
101-
return rand.Intn(Max(Min(serversCount, 2), serversCount/2))
101+
return rand.Intn((serversCount + 1) / 2)
102102
}
103103

104104
func (LBStrategyPH) getActiveCount(serversCount int) int {
105-
return Max(Min(serversCount, 2), serversCount/2)
105+
return (serversCount + 1) / 2
106106
}
107107

108108
type LBStrategyFirst struct{}

0 commit comments

Comments
 (0)