From 4d381d7e90024d72c78b7cee5d40e9de2a24d45f Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Tue, 16 Jun 2020 16:08:18 -0400 Subject: [PATCH] transport/http: don't reuse a base transport between clients (#532) Previously sync.Once was used to cache a fallback base transport. This caused a race condition when setting MaxIdleConnsPerHost and TLSClientConfig in defaultBaseTransport (above). Because of these settings, it isn't valid to share the base transport across clients. I conferred with @neild and determined that it is impossible to implement a transport.Clone for < Go 1.13, so instead we should initialize a new transport with default values each time in this case. Fixes googleapis/google-cloud-go#2405 --- transport/http/dial.go | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/transport/http/dial.go b/transport/http/dial.go index 96cf2e1689c..19a4c9a59eb 100644 --- a/transport/http/dial.go +++ b/transport/http/dial.go @@ -16,7 +16,6 @@ import ( "net/url" "os" "strings" - "sync" "time" "go.opencensus.io/plugin/ochttp" @@ -191,31 +190,23 @@ func defaultBaseTransport(ctx context.Context, clientCertSource cert.Source) htt return trans } -var fallback struct { - *http.Transport - sync.Once -} - // fallbackBaseTransport is used in