Skip to content

Commit 94f812b

Browse files
tiancheng91ginuerzh
authored andcommitted
fix: ping result ttl random
1 parent 2faecc1 commit 94f812b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

selector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func (f *FastestFilter) Filter(nodes []Node) []Node {
240240

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

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

256256
f.mu.Lock()
257257
f.pingResult[node.ID] = latency

0 commit comments

Comments
 (0)