fs/fshttp: limit MaxIdleConns and MaxIdleConnsPerHost

Before this change mega (which uses a different host per download)
would open too many sockets.
This commit is contained in:
Nick Craig-Wood 2018-04-11 14:04:36 +01:00
parent 4b5ff33125
commit 37be78705d

View File

@ -126,7 +126,8 @@ func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
t := new(http.Transport)
setDefaults(t, http.DefaultTransport.(*http.Transport))
t.Proxy = http.ProxyFromEnvironment
t.MaxIdleConnsPerHost = 4 * (ci.Checkers + ci.Transfers + 1)
t.MaxIdleConnsPerHost = 2 * (ci.Checkers + ci.Transfers + 1)
t.MaxIdleConns = 2 * t.MaxIdleConnsPerHost
t.TLSHandshakeTimeout = ci.ConnectTimeout
t.ResponseHeaderTimeout = ci.Timeout
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}