From 169b901c2dca5e3bab60d2dadb94cd408f946acf Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 21 Mar 2018 23:28:28 +0100 Subject: [PATCH] lazy init of dialer map --- transport/internet/http/dialer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 025e314d..b4b83530 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -17,7 +17,7 @@ import ( ) var ( - globalDialerMap = make(map[net.Destination]*http.Client) + globalDialerMap map[net.Destination]*http.Client globalDailerAccess sync.Mutex ) @@ -25,6 +25,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination) (*http.Client, err globalDailerAccess.Lock() defer globalDailerAccess.Unlock() + if globalDialerMap == nil { + globalDialerMap = make(map[net.Destination]*http.Client) + } + if client, found := globalDialerMap[dest]; found { return client, nil }