Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
296f7356e0 | |||
f147fb47bb | |||
b6dfdcd5ef |
@ -172,6 +172,8 @@ func (m measurement) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) probeUpstreamLatency() {
|
func (s *Server) probeUpstreamLatency() {
|
||||||
|
if !s.once {
|
||||||
|
s.once = true
|
||||||
upstreams := s.upstreams()
|
upstreams := s.upstreams()
|
||||||
results := make([]measurement, len(upstreams))
|
results := make([]measurement, len(upstreams))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@ -199,7 +201,7 @@ func (s *Server) probeUpstreamLatency() {
|
|||||||
sort.Slice(results, func(i, j int) bool {
|
sort.Slice(results, func(i, j int) bool {
|
||||||
return results[i].rtt < results[j].rtt
|
return results[i].rtt < results[j].rtt
|
||||||
})
|
})
|
||||||
log.Printf("probe results: %v", results)
|
log.Printf("probe results: %v %v", s.once, results)
|
||||||
for idx, result := range results {
|
for idx, result := range results {
|
||||||
upstreams[idx] = result.upstream
|
upstreams[idx] = result.upstream
|
||||||
}
|
}
|
||||||
@ -207,6 +209,7 @@ func (s *Server) probeUpstreamLatency() {
|
|||||||
defer s.upstreamMu.Unlock()
|
defer s.upstreamMu.Unlock()
|
||||||
s.upstream = upstreams
|
s.upstream = upstreams
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) hostByName(n lcHostname) (string, bool) {
|
func (s *Server) hostByName(n lcHostname) (string, bool) {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
Reference in New Issue
Block a user