From 37be78705db7aff3bbdd502f2af3a0073f590351 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 11 Apr 2018 14:04:36 +0100 Subject: [PATCH] fs/fshttp: limit MaxIdleConns and MaxIdleConnsPerHost Before this change mega (which uses a different host per download) would open too many sockets. --- fs/fshttp/http.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fshttp/http.go b/fs/fshttp/http.go index 9566d58f8..642acbc1e 100644 --- a/fs/fshttp/http.go +++ b/fs/fshttp/http.go @@ -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}