Skip to content

Commit

Permalink
fix: ping result ttl random
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancheng91 authored and ginuerzh committed Jun 13, 2024
1 parent 2faecc1 commit 94f812b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func (f *FastestFilter) Filter(nodes []Node) []Node {

// get latency with ttl cache
now := time.Now().Unix()
r := rand.New(rand.NewSource(time.Now().UnixNano()))

var getNodeLatency = func(node Node) int {
if f.pingResultTTL[node.ID] < now {
Expand All @@ -251,7 +250,8 @@ func (f *FastestFilter) Filter(nodes []Node) []Node {
// get latency
go func(node Node) {
latency := f.doTcpPing(node.Addr)
ttl := 300 - int64(60*r.Float64())
r := rand.New(rand.NewSource(time.Now().UnixNano()))
ttl := 300 - int64(120*r.Float64())

f.mu.Lock()
f.pingResult[node.ID] = latency
Expand Down

0 comments on commit 94f812b

Please sign in to comment.