initialize forwarder after init() to avoid crashes (#11330)

DNSCache dialer is a global value initialized in
init(), whereas `go` keeps `var =` before `init()`
, also we don't need to keep proxy routers as
global entities - register the forwarder as
necessary to avoid crashes.
This commit is contained in:
Harshavardhana
2021-01-22 15:37:41 -08:00
committed by GitHub
parent a6c146bd00
commit 1b453728a3
3 changed files with 15 additions and 11 deletions
+10
View File
@@ -41,6 +41,7 @@ import (
"github.com/minio/minio/pkg/certs"
"github.com/minio/minio/pkg/console"
"github.com/minio/minio/pkg/env"
"github.com/minio/minio/pkg/handlers"
)
// serverDebugLog will enable debug printing
@@ -51,10 +52,19 @@ func init() {
logger.RegisterError(config.FmtError)
rand.Seed(time.Now().UTC().UnixNano())
globalDNSCache = xhttp.NewDNSCache(10*time.Second, 10*time.Second, logger.LogOnceIf)
initGlobalContext()
globalForwarder = handlers.NewForwarder(&handlers.Forwarder{
PassHost: true,
RoundTripper: newGatewayHTTPTransport(1 * time.Hour),
Logger: func(err error) {
logger.LogIf(GlobalContext, err)
},
})
globalReplicationState = newReplicationState()
globalTransitionState = newTransitionState()