From 91a520b069096099d5d01fb41dc17d3422fb5929 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 3 Dec 2025 09:53:50 +0000 Subject: [PATCH] fix: remove unnecessary RUnlock --- pkg/store/objectstore/flatfs/flatfs.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/store/objectstore/flatfs/flatfs.go b/pkg/store/objectstore/flatfs/flatfs.go index df97f970..380b7c40 100644 --- a/pkg/store/objectstore/flatfs/flatfs.go +++ b/pkg/store/objectstore/flatfs/flatfs.go @@ -109,14 +109,19 @@ func (m *opMap) Begin(name string) *opResult { } op := opIface.(*opResult) - // someone else doing ops with this key, wait for - // the result + // someone else doing ops with this key, wait for the + // result Note: we are using `op.mu` as a syncing + // primitive to make several threads WAIT. The first + // operation will grab the write-lock. Everyone else + // tries to grab a read-lock as a way of waiting for + // the operation to be finished by the thead that + // grabbed the write-lock. The Read-lock does not need + // to be unlocked, as the operation is never used or + // re-used for anything else from that point. op.mu.RLock() if op.success { - op.mu.RUnlock() return nil } - op.mu.RUnlock() // if we are here, we will retry the operation }