From b6f74b66d53e2f4bc59ef574a4b6bedb61e5185c Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Fri, 11 Mar 2016 09:24:10 +0000 Subject: [PATCH] Protect http client cache with mutex --- lfs/config.go | 1 + lfs/http.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lfs/config.go b/lfs/config.go index f405679f..ca9164d8 100644 --- a/lfs/config.go +++ b/lfs/config.go @@ -46,6 +46,7 @@ type FetchPruneConfig struct { type Configuration struct { CurrentRemote string httpClients map[string]*HttpClient + httpClientsMutex sync.Mutex redirectingHttpClient *http.Client ntlmSession ntlm.ClientSession envVars map[string]string diff --git a/lfs/http.go b/lfs/http.go index 6067dcce..ecce0b75 100644 --- a/lfs/http.go +++ b/lfs/http.go @@ -100,6 +100,9 @@ func (c *HttpClient) Do(req *http.Request) (*http.Response, error) { // HttpClient returns a new HttpClient for the given host (which may be "host:port") func (c *Configuration) HttpClient(host string) *HttpClient { + c.httpClientsMutex.Lock() + defer c.httpClientsMutex.Unlock() + if c.httpClients == nil { c.httpClients = make(map[string]*HttpClient) }