diff --git a/client.go b/client.go index 8800571..d37ed33 100644 --- a/client.go +++ b/client.go @@ -501,6 +501,10 @@ func (c *Client) Do(req *Request, resp *Response) error { m = c.ms } hc := m[string(host)] + if hc != nil { + atomic.AddInt32(&hc.pendingClientRequests, 1) + defer atomic.AddInt32(&hc.pendingClientRequests, -1) + } c.mLock.RUnlock() if hc == nil { c.mLock.Lock() @@ -545,12 +549,11 @@ func (c *Client) Do(req *Request, resp *Response) error { startCleaner = true } } + atomic.AddInt32(&hc.pendingClientRequests, 1) + defer atomic.AddInt32(&hc.pendingClientRequests, -1) c.mLock.Unlock() } - atomic.AddInt32(&hc.pendingClientRequests, 1) - defer atomic.AddInt32(&hc.pendingClientRequests, -1) - if startCleaner { go c.mCleaner(m) }