mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
lock: Shrink critical section in RefreshStaleLock
A cleaning up after a failed lock refresh attempt does not require a mutex.
This commit is contained in:
parent
76253b2a20
commit
3f63b53090
@ -306,15 +306,15 @@ func (l *Lock) RefreshStaleLock(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
l.lock.Lock()
|
|
||||||
defer l.lock.Unlock()
|
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
// cleanup replacement lock
|
// cleanup replacement lock
|
||||||
_ = l.repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: id.String()})
|
_ = l.repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: id.String()})
|
||||||
return ErrRemovedLock
|
return ErrRemovedLock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.lock.Lock()
|
||||||
|
defer l.lock.Unlock()
|
||||||
|
|
||||||
debug.Log("new lock ID %v", id)
|
debug.Log("new lock ID %v", id)
|
||||||
oldLockID := l.lockID
|
oldLockID := l.lockID
|
||||||
l.lockID = &id
|
l.lockID = &id
|
||||||
|
Loading…
Reference in New Issue
Block a user