From 705e8f2fe0ab14ac71ed00bf53d3f1b8fc3b3db7 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 15 Nov 2022 09:32:36 +0000 Subject: [PATCH] smb: fix Failed to sync: context canceled at the end of syncs Before this change we were putting connections into the connection pool which had a local context in. This meant that when the operation had finished the context was cancelled and the connection became unusable. See: https://forum.rclone.org/t/failed-to-sync-context-canceled/34017/ --- backend/smb/connpool.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/smb/connpool.go b/backend/smb/connpool.go index 6f6fe8232..d4bed787c 100644 --- a/backend/smb/connpool.go +++ b/backend/smb/connpool.go @@ -103,6 +103,10 @@ func (f *Fs) getSessions() int32 { // Open a new connection to the SMB server. func (f *Fs) newConnection(ctx context.Context, share string) (c *conn, err error) { + // As we are pooling these connections we need to decouple + // them from the current context + ctx = context.Background() + c, err = f.dial(ctx, "tcp", f.opt.Host+":"+f.opt.Port) if err != nil { return nil, fmt.Errorf("couldn't connect SMB: %w", err)