Commit 0876a38c authored by Miek Gieben's avatar Miek Gieben

middleware/httproxy: smaller timeouts

Make the timeouts smaller after we fail to connect.
parent 96222927
...@@ -73,7 +73,7 @@ func (g *google) Exchange(req *dns.Msg) (*dns.Msg, error) { ...@@ -73,7 +73,7 @@ func (g *google) Exchange(req *dns.Msg) (*dns.Msg, error) {
timeout := addr.FailTimeout timeout := addr.FailTimeout
if timeout == 0 { if timeout == 0 {
timeout = 10 * time.Second timeout = 5 * time.Second
} }
atomic.AddInt32(&addr.Fails, 1) atomic.AddInt32(&addr.Fails, 1)
go func(host *proxy.UpstreamHost, timeout time.Duration) { go func(host *proxy.UpstreamHost, timeout time.Duration) {
...@@ -185,7 +185,7 @@ func (g *google) lookup(r *dns.Msg) ([]string, error) { ...@@ -185,7 +185,7 @@ func (g *google) lookup(r *dns.Msg) ([]string, error) {
timeout := host.FailTimeout timeout := host.FailTimeout
if timeout == 0 { if timeout == 0 {
timeout = 10 * time.Second timeout = 7 * time.Second
} }
atomic.AddInt32(&host.Fails, 1) atomic.AddInt32(&host.Fails, 1)
go func(host *proxy.UpstreamHost, timeout time.Duration) { go func(host *proxy.UpstreamHost, timeout time.Duration) {
......
...@@ -22,7 +22,7 @@ func newSimpleUpstream(hosts []string) (*simpleUpstream, error) { ...@@ -22,7 +22,7 @@ func newSimpleUpstream(hosts []string) (*simpleUpstream, error) {
upstream := &simpleUpstream{ upstream := &simpleUpstream{
Hosts: nil, Hosts: nil,
Policy: &proxy.Random{}, Policy: &proxy.Random{},
FailTimeout: 10 * time.Second, FailTimeout: 3 * time.Second,
MaxFails: 3, MaxFails: 3,
} }
......
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