From 45f45c987c6aeb7ae250593f02a0c9efc1149893 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 11 Sep 2025 17:27:15 +0100 Subject: [PATCH] march: fix deadlock when using --fast-list on syncs - fixes #8811 Before this change, it was possible to have a deadlock when using --fast-list for a sync if both the source and destination supported ListR. This fixes the problem by shortening the locking window. --- fs/march/march.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/march/march.go b/fs/march/march.go index 67a5b5bfa..841ca4cc7 100644 --- a/fs/march/march.go +++ b/fs/march/march.go @@ -137,20 +137,22 @@ func (m *March) makeListDir(ctx context.Context, f fs.Fs, includeAll bool, keyFn ) return func(dir string, callback fs.ListRCallback) (err error) { mu.Lock() - defer mu.Unlock() if !started { dirCtx := filter.SetUseFilter(m.Ctx, f.Features().FilterAware && !includeAll) // make filter-aware backends constrain List dirs, dirsErr = walk.NewDirTree(dirCtx, f, m.Dir, includeAll, ci.MaxDepth) started = true } if dirsErr != nil { + mu.Unlock() return dirsErr } entries, ok := dirs[dir] if !ok { + mu.Unlock() return fs.ErrorDirNotFound } delete(dirs, dir) + mu.Unlock() // We use a stable sort here just in case there are // duplicates. Assuming the remote delivers the entries in a