Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
2cece747
Commit
2cece747
authored
2 years ago
by
benjamin
Browse files
Options
Downloads
Patches
Plain Diff
host pool fix
parent
bd006184
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmix/gateway/hostPool.go
+14
-5
14 additions, 5 deletions
cmix/gateway/hostPool.go
with
14 additions
and
5 deletions
cmix/gateway/hostPool.go
+
14
−
5
View file @
2cece747
...
...
@@ -318,10 +318,11 @@ func (h *HostPool) initialize(startIdx uint32) error {
// Begin trying gateways
c
:=
make
(
chan
gatewayDuration
,
numGatewaysToTry
)
exit
:=
false
i
:=
uint32
(
0
)
for
!
exit
{
for
;
i
<
numGateways
;
i
++
{
i
:=
0
for
exit
:=
false
;
!
exit
;
{
triedHosts
:=
uint32
(
0
)
for
;
triedHosts
<
numGateways
&&
i
<
len
(
randomGateways
);
i
++
{
// Select a gateway not yet selected
gwId
,
err
:=
randomGateways
[
i
]
.
GetGatewayId
()
if
err
!=
nil
{
...
...
@@ -332,6 +333,7 @@ func (h *HostPool) initialize(startIdx uint32) error {
if
_
,
ok
:=
h
.
hostMap
[
*
gwId
];
ok
{
continue
}
triedHosts
++
go
func
()
{
// Obtain that GwId's Host object
...
...
@@ -352,19 +354,22 @@ func (h *HostPool) initialize(startIdx uint32) error {
// Collect ping results
pingTimeout
:=
2
*
h
.
poolParams
.
HostParams
.
PingTimeout
timer
:=
time
.
NewTimer
(
pingTimeout
)
newAppends
:=
uint32
(
0
)
innerLoop
:
for
{
select
{
case
gw
:=
<-
c
:
// Only add successful pings
if
gw
.
latency
>
0
{
newAppends
++
resultList
=
append
(
resultList
,
gw
)
jww
.
DEBUG
.
Printf
(
"Adding HostPool result %d/%d: %s: %d"
,
len
(
resultList
),
numGatewaysToTry
,
gw
.
id
,
gw
.
latency
)
}
// Break if we have all needed slots
if
uint32
(
len
(
resultList
))
==
numGatewaysToTry
||
i
>=
numGateway
s
{
if
newAppends
==
triedHost
s
{
exit
=
true
timer
.
Stop
()
break
innerLoop
...
...
@@ -376,6 +381,10 @@ func (h *HostPool) initialize(startIdx uint32) error {
break
innerLoop
}
}
if
i
>=
len
(
randomGateways
)
{
exit
=
true
}
}
// Sort the resultList by lowest latency
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment