From 3a1a2ddfc8e3aea6bacdca4f5427ece9cd93ac0c Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 23 Nov 2015 12:26:32 +0200 Subject: [PATCH] Randomize sleep time in Client.DoTimeout when waiting for free connection to the host --- client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index b12f5b5..9130024 100644 --- a/client.go +++ b/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "io" + "math/rand" "net" "strconv" "strings" @@ -441,7 +442,7 @@ func clientDoTimeout(req *Request, resp *Response, timeout time.Duration, c clie if timeout <= 0 { return ErrTimeout } - sleepTime := 100 * time.Millisecond + sleepTime := (10 + time.Duration(rand.Intn(100))) * time.Millisecond if sleepTime > timeout { sleepTime = timeout }