Commit 573ad62b authored by Miek Gieben's avatar Miek Gieben Committed by John Belamaric

plugin/forward: min and max for avgRTT (#1680)

* Move to readtimeout

* lets compile

* address comment

* comment from pr

* much smaller minimum
parent cd7928f1
...@@ -18,10 +18,14 @@ import ( ...@@ -18,10 +18,14 @@ import (
func (p *Proxy) readTimeout() time.Duration { func (p *Proxy) readTimeout() time.Duration {
rtt := time.Duration(atomic.LoadInt64(&p.avgRtt)) rtt := time.Duration(atomic.LoadInt64(&p.avgRtt))
if rtt < timeout/2 {
if rtt < minTimeout {
return minTimeout
}
if rtt < maxTimeout/2 {
return 2 * rtt return 2 * rtt
} }
return timeout return maxTimeout
} }
func (p *Proxy) updateRtt(newRtt time.Duration) { func (p *Proxy) updateRtt(newRtt time.Duration) {
......
...@@ -91,5 +91,7 @@ func (p *Proxy) start(duration time.Duration) { p.probe.Start(duration) } ...@@ -91,5 +91,7 @@ func (p *Proxy) start(duration time.Duration) { p.probe.Start(duration) }
const ( const (
dialTimeout = 4 * time.Second dialTimeout = 4 * time.Second
timeout = 2 * time.Second timeout = 2 * time.Second
maxTimeout = 2 * time.Second
minTimeout = 10 * time.Millisecond
hcDuration = 500 * time.Millisecond hcDuration = 500 * time.Millisecond
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment