Merge pull request #4403 from cli/cs-concurrent-requests

Don't allow the lazyLoadedHTTPClient mutex to wrap `Do()`
This commit is contained in:
Mislav Marohnić 2021-10-01 17:26:04 +02:00 committed by GitHub
commit cb6db95ec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,14 +151,14 @@ func (l *lazyLoadedHTTPClient) Do(req *http.Request) (*http.Response, error) {
l.httpClientMu.RUnlock()
if httpClient == nil {
l.httpClientMu.Lock()
defer l.httpClientMu.Unlock()
var err error
l.httpClientMu.Lock()
l.httpClient, err = l.factory.HttpClient()
l.httpClientMu.Unlock()
if err != nil {
return nil, err
}
}
return l.httpClient.Do(req)
}