diff --git a/main.go b/main.go index f0dd1eb..a403e93 100644 --- a/main.go +++ b/main.go @@ -643,13 +643,10 @@ type roundTripperWrapper struct { clientCert string clientKey string insecure bool - rwLocker sync.RWMutex - transport http.RoundTripper + transport atomic.Pointer[http.Transport] } func (rtw *roundTripperWrapper) renew() { - rtw.rwLocker.Lock() - defer rtw.rwLocker.Unlock() dnsCache.Refresh() tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, @@ -683,13 +680,11 @@ func (rtw *roundTripperWrapper) renew() { ClientSessionCache: tls.NewLRUClientSessionCache(tlsClientSessionCacheSize), } } - rtw.transport = tr + rtw.transport.Store(tr) } func (rtw *roundTripperWrapper) RoundTrip(req *http.Request) (*http.Response, error) { - rtw.rwLocker.RLock() - defer rtw.rwLocker.RUnlock() - return rtw.transport.RoundTrip(req) + return rtw.transport.Load().RoundTrip(req) } func clientTransport(ctx *cli.Context, enableTLS bool) http.RoundTripper {