locking: Fix wrong map id (#14184)

Wrong resource is being fetched, since idx is incremented, but mapID is reused.

Regression caused by #13454 - that part didn't optimize anything anyway.
This commit is contained in:
Klaus Post
2022-01-26 08:34:09 -08:00
committed by GitHub
parent a8ba71edef
commit 7db05a80dd

View File

@@ -322,11 +322,10 @@ func (l *localLocker) Refresh(ctx context.Context, args dsync.LockArgs) (refresh
} }
idx := 0 idx := 0
for { for {
mapID := formatUUID(args.UID, idx)
lris, ok := l.lockMap[resource] lris, ok := l.lockMap[resource]
if !ok { if !ok {
// Inconsistent. Delete UID. // Inconsistent. Delete UID.
delete(l.lockUID, mapID) delete(l.lockUID, formatUUID(args.UID, idx))
return idx > 0, nil return idx > 0, nil
} }
for i := range lris { for i := range lris {
@@ -335,7 +334,7 @@ func (l *localLocker) Refresh(ctx context.Context, args dsync.LockArgs) (refresh
} }
} }
idx++ idx++
resource, ok = l.lockUID[mapID] resource, ok = l.lockUID[formatUUID(args.UID, idx)]
if !ok { if !ok {
// No more resources for UID, but we did update at least one. // No more resources for UID, but we did update at least one.
return true, nil return true, nil