mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
Merge pull request #32559 from guangxuli/k8s_lock
Automatic merge from submit-queue the lockfile should be handled after function return
This commit is contained in:
commit
c1e8c6d878
@ -42,7 +42,7 @@ func Acquire(path string) error {
|
|||||||
if lockfile, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600); err != nil {
|
if lockfile, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer lockfile.Close()
|
||||||
opts := unix.Flock_t{Type: unix.F_WRLCK}
|
opts := unix.Flock_t{Type: unix.F_WRLCK}
|
||||||
if err := unix.FcntlFlock(lockfile.Fd(), unix.F_SETLKW, &opts); err != nil {
|
if err := unix.FcntlFlock(lockfile.Fd(), unix.F_SETLKW, &opts); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user