Fix goroutines change DialContext of http.DefaultTransport in router (#1063)
This commit is contained in:
@@ -183,10 +183,7 @@ func (roundTripper RetryingRoundTripper) RoundTrip(req *http.Request) (resp *htt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the timeout for transport context
|
// set the timeout for transport context
|
||||||
transport := http.DefaultTransport.(*http.Transport)
|
transport := roundTripper.getDefaultTransport()
|
||||||
|
|
||||||
// Disables caching, Please refer to issue and specifically comment: https://github.com/fission/fission/issues/723#issuecomment-398781995
|
|
||||||
transport.DisableKeepAlives = true
|
|
||||||
|
|
||||||
executingTimeout := roundTripper.funcHandler.tsRoundTripperParams.timeout
|
executingTimeout := roundTripper.funcHandler.tsRoundTripperParams.timeout
|
||||||
|
|
||||||
@@ -346,6 +343,26 @@ func (roundTripper RetryingRoundTripper) RoundTrip(req *http.Request) (resp *htt
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getDefaultTransport returns a pointer to new copy of http.Transport object to prevent
|
||||||
|
// the value of http.DefaultTransport from being changed by goroutines.
|
||||||
|
func (roundTripper RetryingRoundTripper) getDefaultTransport() *http.Transport {
|
||||||
|
// The transport setup here follows the configurations of http.DefaultTransport
|
||||||
|
// but without Dialer since we will change it later.
|
||||||
|
transport := http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disables caching, Please refer to issue and specifically
|
||||||
|
// comment: https://github.com/fission/fission/issues/723#issuecomment-398781995
|
||||||
|
transport.DisableKeepAlives = true
|
||||||
|
|
||||||
|
return &transport
|
||||||
|
}
|
||||||
|
|
||||||
func (fh *functionHandler) tapService(serviceUrl *url.URL) {
|
func (fh *functionHandler) tapService(serviceUrl *url.URL) {
|
||||||
if fh.executor == nil {
|
if fh.executor == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user