Skip to content

Commit 8c0e3c0

Browse files
committed
fix review findings
1 parent 86ce450 commit 8c0e3c0

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

controllers/remote/keyedmutex.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import (
2727
// A second Lock call if the lock is already held for a key returns false.
2828
type keyedMutex struct {
2929
locksMtx sync.Mutex
30-
locks map[client.ObjectKey]*sync.Mutex
30+
locks map[client.ObjectKey]bool
3131
}
3232

3333
// newKeyedMutex creates a new keyed mutex ready for use.
3434
func newKeyedMutex() *keyedMutex {
3535
return &keyedMutex{
36-
locks: make(map[client.ObjectKey]*sync.Mutex),
36+
locks: make(map[client.ObjectKey]bool),
3737
}
3838
}
3939

@@ -50,10 +50,8 @@ func (k *keyedMutex) TryLock(key client.ObjectKey) bool {
5050
return false
5151
}
5252

53-
// Lock doesn't exist yet, create and lock the lock.
54-
l := &sync.Mutex{}
55-
k.locks[key] = l
56-
l.Lock()
53+
// Lock doesn't exist yet, create the lock.
54+
k.locks[key] = true
5755

5856
return true
5957
}
@@ -63,8 +61,7 @@ func (k *keyedMutex) Unlock(key client.ObjectKey) {
6361
k.locksMtx.Lock()
6462
defer k.locksMtx.Unlock()
6563

66-
if l, ok := k.locks[key]; ok {
67-
l.Unlock()
64+
if k.locks[key] {
6865
delete(k.locks, key)
6966
}
7067
}

0 commit comments

Comments
 (0)