From 811b30d11604d4bec8c95a13bb22d6b10203cef3 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 15 Jul 2020 15:05:44 +0100 Subject: [PATCH] sync: fix deadlock with --track-renames-strategy modtime - fixes #4427 Before this change we could exit the popRenameMap function with the lock held. This fixes the problem by defer-ring the unlock. See: https://forum.rclone.org/t/track-renames-strategy-modtime-doesnt-work/16992 --- fs/sync/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/sync/sync.go b/fs/sync/sync.go index b915b7d26..4a3c2b01a 100644 --- a/fs/sync/sync.go +++ b/fs/sync/sync.go @@ -658,6 +658,7 @@ func (s *syncCopyMove) pushRenameMap(hash string, obj fs.Object) { // renameMap or returns nil if not found. func (s *syncCopyMove) popRenameMap(hash string, src fs.Object) (dst fs.Object) { s.renameMapMu.Lock() + defer s.renameMapMu.Unlock() dsts, ok := s.renameMap[hash] if ok && len(dsts) > 0 { // Element to remove @@ -690,7 +691,6 @@ func (s *syncCopyMove) popRenameMap(hash string, src fs.Object) (dst fs.Object) delete(s.renameMap, hash) } } - s.renameMapMu.Unlock() return dst }