From fd2322cb41d6e06882c23b8ffac2ef992853b813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=A0=E7=9F=A5=E9=81=93=E6=9C=AA=E6=9D=A5=E5=90=97?= Date: Sat, 25 Nov 2023 01:53:33 +0800 Subject: [PATCH] fs/fshttp: fix --contimeout being ignored The following command will block for 60s(default) when the network is slow or unavailable: ``` rclone --contimeout 10s --low-level-retries 0 lsd dropbox: ``` This change will make it timeout after the expected 10s. Signed-off-by: rkonfj --- fs/fshttp/dialer.go | 4 ---- fs/fshttp/http.go | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/fshttp/dialer.go b/fs/fshttp/dialer.go index a41b478b8..a8ff67bc6 100644 --- a/fs/fshttp/dialer.go +++ b/fs/fshttp/dialer.go @@ -14,10 +14,6 @@ import ( "golang.org/x/net/ipv6" ) -func dialContext(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) { - return NewDialer(ctx).DialContext(ctx, network, address) -} - // Dialer structure contains default dialer and timeout, tclass support type Dialer struct { net.Dialer diff --git a/fs/fshttp/http.go b/fs/fshttp/http.go index f17c8298e..498714dfd 100644 --- a/fs/fshttp/http.go +++ b/fs/fshttp/http.go @@ -91,8 +91,8 @@ func NewTransportCustom(ctx context.Context, customize func(*http.Transport)) ht } t.DisableCompression = ci.NoGzip - t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { - return dialContext(ctx, network, addr, ci) + t.DialContext = func(reqCtx context.Context, network, addr string) (net.Conn, error) { + return NewDialer(ctx).DialContext(reqCtx, network, addr) } t.IdleConnTimeout = 60 * time.Second t.ExpectContinueTimeout = ci.ExpectContinueTimeout