mirror of
https://github.com/pgsty/minio.git
synced 2026-10-08 18:55:58 +03:00
fix: cleanup locking, cancel context upon lock timeout (#12183)
upon errors to acquire lock context would still leak, since the cancel would never be called. since the lock is never acquired - proactively clear it before returning.
This commit is contained in:
@@ -253,12 +253,13 @@ func (er erasureObjects) healObject(ctx context.Context, bucket string, object s
|
||||
}
|
||||
|
||||
if !opts.NoLock {
|
||||
var cancel context.CancelFunc
|
||||
lk := er.NewNSLock(bucket, object)
|
||||
if ctx, cancel, err = lk.GetLock(ctx, globalOperationTimeout); err != nil {
|
||||
lkctx, err := lk.GetLock(ctx, globalOperationTimeout)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
defer lk.Unlock(cancel)
|
||||
ctx = lkctx.Context()
|
||||
defer lk.Unlock(lkctx.Cancel)
|
||||
}
|
||||
|
||||
// Re-read when we have lock...
|
||||
|
||||
Reference in New Issue
Block a user