Randomize sleep time in Client.DoTimeout when waiting for free connection to the host

This commit is contained in:
Aliaksandr Valialkin
2015-11-23 12:26:32 +02:00
parent 295e2bcd15
commit 3a1a2ddfc8
+2 -1
View File
@@ -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
}