From 406dec29a742b49438e8d79a8a6a5d87a0518234 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 8 Jun 2026 22:14:12 +0200 Subject: [PATCH] repository: remove redundant mutex in checkForOtherLocks forAllLocks already serializes the callback calls. Still has to create a copy of checkedIDs to prevent a data race between forAllLocks and the callback. --- internal/repository/lock_file.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/repository/lock_file.go b/internal/repository/lock_file.go index 8002aaf7e..cdc295f0d 100644 --- a/internal/repository/lock_file.go +++ b/internal/repository/lock_file.go @@ -173,8 +173,7 @@ func (l *lockHandle) checkForOtherLocks(ctx context.Context) error { delay *= 2 } - // Store updates in new IDSet to prevent data races - var m sync.Mutex + // Store updates in new IDSet to prevent data races with Has() check in forAllLocks newCheckedIDs := checkedIDs.Clone() err = forAllLocks(ctx, l.repo, checkedIDs, func(id restic.ID, lock *lockHandle, err error) error { if err != nil { @@ -189,9 +188,7 @@ func (l *lockHandle) checkForOtherLocks(ctx context.Context) error { } // valid locks will remain valid - m.Lock() newCheckedIDs.Insert(id) - m.Unlock() return nil }) checkedIDs = newCheckedIDs