diff --git a/probe/appclient/app_client.go b/probe/appclient/app_client.go index 31837093b..84a47fec6 100644 --- a/probe/appclient/app_client.go +++ b/probe/appclient/app_client.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "io/ioutil" + "net" "net/http" "net/rpc" "sync" @@ -20,6 +21,7 @@ import ( const ( initialBackoff = 1 * time.Second maxBackoff = 60 * time.Second + dialTimeout = 5 * time.Second ) // AppClient is a client to an app for dealing with controls. @@ -64,6 +66,10 @@ func NewAppClient(pc ProbeConfig, hostname, target string, control xfer.ControlH return nil, err } + httpTransport.Dial = func(network, addr string) (net.Conn, error) { + return net.DialTimeout(network, addr, dialTimeout) + } + return &appClient{ ProbeConfig: pc, quit: make(chan struct{}), diff --git a/probe/appclient/resolver.go b/probe/appclient/resolver.go index 97037d783..cd5031785 100644 --- a/probe/appclient/resolver.go +++ b/probe/appclient/resolver.go @@ -17,9 +17,30 @@ const ( ) var ( - tick = time.Tick + tick = fastStartTicker ) +// fastStartTicker is a ticker that 'ramps up' from 1 sec to duration. +func fastStartTicker(duration time.Duration) <-chan time.Time { + c := make(chan time.Time, 1) + go func() { + d := 1 * time.Second + for { + time.Sleep(d) + d = d * 2 + if d > duration { + d = duration + } + + select { + case c <- time.Now(): + default: + } + } + }() + return c +} + type setter func(string, []string) // Resolver is a thing that can be stopped...