From dec5ac841cc2d172c25f621f6cd04260ecf36df1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 22 Nov 2015 01:10:41 +0200 Subject: [PATCH] Fixed a bug with improper HostClient map updating in Client.Do. This bug led to new HostClient creation on each Client.Do request --- client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 4b4aa40..1955770 100644 --- a/client.go +++ b/client.go @@ -199,7 +199,7 @@ func (c *Client) Do(req *Request, resp *Response) error { if isTLS { hc.IsTLS = true } - m[hc.Addr] = hc + m[string(host)] = hc if len(m) == 1 { startCleaner = true } @@ -583,8 +583,9 @@ func (c *HostClient) acquireConn(newConn bool) (*clientConn, error) { createConn := false startCleaner := false + var n int c.connsLock.Lock() - n := len(c.conns) + n = len(c.conns) if n == 0 || newConn { maxConns := c.MaxConns if maxConns <= 0 {