X Tutup
Skip to content

Commit a723813

Browse files
committed
Don't allow the lazyLoadedHTTPClient mutex to wrap Do()
We only need a mutex around accessing `l.httpClient`, but never around the actual HTTP request.
1 parent be22cab commit a723813

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/cmd/root/root.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ func (l *lazyLoadedHTTPClient) Do(req *http.Request) (*http.Response, error) {
151151
l.httpClientMu.RUnlock()
152152

153153
if httpClient == nil {
154-
l.httpClientMu.Lock()
155-
defer l.httpClientMu.Unlock()
156-
157154
var err error
155+
l.httpClientMu.Lock()
158156
l.httpClient, err = l.factory.HttpClient()
157+
l.httpClientMu.Unlock()
159158
if err != nil {
160159
return nil, err
161160
}
162161
}
162+
163163
return l.httpClient.Do(req)
164164
}

0 commit comments

Comments
 (0)
X Tutup