Skip to content
Snippets Groups Projects
Commit e6e5bd56 authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'xx-4261/hostpool-size-fix' into 'project/Channels'

Fix host pool size checking

See merge request !414
parents 185226c4 83dbe4c7
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!414Fix host pool size checking,!340Project/channels
...@@ -307,11 +307,13 @@ func (h *HostPool) initialize(startIdx uint32) error { ...@@ -307,11 +307,13 @@ func (h *HostPool) initialize(startIdx uint32) error {
id *id.ID id *id.ID
latency time.Duration latency time.Duration
} }
numGatewaysToTry := h.poolParams.MaxPings numGatewaysToTry := h.poolParams.MaxPings
numGateways := uint32(len(randomGateways)) numGateways := uint32(len(randomGateways))
if numGatewaysToTry > numGateways { if numGatewaysToTry > numGateways {
numGatewaysToTry = numGateways numGatewaysToTry = numGateways
} }
resultList := make([]gatewayDuration, 0, numGatewaysToTry) resultList := make([]gatewayDuration, 0, numGatewaysToTry)
// Begin trying gateways // Begin trying gateways
...@@ -320,12 +322,6 @@ func (h *HostPool) initialize(startIdx uint32) error { ...@@ -320,12 +322,6 @@ func (h *HostPool) initialize(startIdx uint32) error {
i := uint32(0) i := uint32(0)
for !exit { for !exit {
for ; i < numGateways; i++ { for ; i < numGateways; i++ {
// Ran out of Hosts to try
if i >= numGateways {
exit = true
break
}
// Select a gateway not yet selected // Select a gateway not yet selected
gwId, err := randomGateways[i].GetGatewayId() gwId, err := randomGateways[i].GetGatewayId()
if err != nil { if err != nil {
...@@ -334,8 +330,6 @@ func (h *HostPool) initialize(startIdx uint32) error { ...@@ -334,8 +330,6 @@ func (h *HostPool) initialize(startIdx uint32) error {
// Skip if already in HostPool // Skip if already in HostPool
if _, ok := h.hostMap[*gwId]; ok { if _, ok := h.hostMap[*gwId]; ok {
// Try another Host instead
numGatewaysToTry++
continue continue
} }
...@@ -370,7 +364,7 @@ func (h *HostPool) initialize(startIdx uint32) error { ...@@ -370,7 +364,7 @@ func (h *HostPool) initialize(startIdx uint32) error {
} }
// Break if we have all needed slots // Break if we have all needed slots
if uint32(len(resultList)) == numGatewaysToTry { if uint32(len(resultList)) == numGatewaysToTry || i >= numGateways {
exit = true exit = true
timer.Stop() timer.Stop()
break innerLoop break innerLoop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment