From 9decd4d0ace451c8b50749cceb31b28ebbc20741 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 24 Nov 2015 17:33:25 +0200 Subject: [PATCH] Properly handle negative timeouts in client's DoTimeout --- client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client.go b/client.go index b2522df..898fa05 100644 --- a/client.go +++ b/client.go @@ -454,6 +454,10 @@ func (c *HostClient) DoTimeout(req *Request, resp *Response, timeout time.Durati } func clientDoTimeout(req *Request, resp *Response, timeout time.Duration, c clientDoer) error { + if timeout <= 0 { + return ErrTimeout + } + deadline := time.Now().Add(timeout) for { err := clientDoTimeoutFreeConn(req, resp, timeout, c)