mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
fix: potential deadLock caused by unlocking a non-existing lock (#15635)
This commit is contained in:
parent
37e3f5de10
commit
f4c56026a2
@ -60,15 +60,6 @@ func (l *localLocker) String() string {
|
||||
return globalEndpoints.Localhost()
|
||||
}
|
||||
|
||||
func (l *localLocker) canTakeUnlock(resources ...string) bool {
|
||||
for _, resource := range resources {
|
||||
if !isWriteLock(l.lockMap[resource]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (l *localLocker) canTakeLock(resources ...string) bool {
|
||||
for _, resource := range resources {
|
||||
_, lockTaken := l.lockMap[resource]
|
||||
@ -129,12 +120,12 @@ func (l *localLocker) Unlock(_ context.Context, args dsync.LockArgs) (reply bool
|
||||
err = nil
|
||||
|
||||
for _, resource := range args.Resources {
|
||||
if !l.canTakeUnlock(resource) {
|
||||
lri, ok := l.lockMap[resource]
|
||||
if ok && !isWriteLock(lri) {
|
||||
// Unless it is a write lock reject it.
|
||||
err = fmt.Errorf("unlock attempted on a read locked entity: %s", resource)
|
||||
continue
|
||||
}
|
||||
lri, ok := l.lockMap[resource]
|
||||
if ok {
|
||||
reply = l.removeEntry(resource, args, &lri) || reply
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user