From a7238130643528bfb29499db8853cae73640788c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 1 Oct 2021 11:18:15 +0200 Subject: [PATCH] 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. --- pkg/cmd/root/root.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index f96922f9f..87702d976 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -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) }