Commit 05d0c720 authored by guangxuli's avatar guangxuli

the lockfile should be handled after function return

parent ba3ab80b
...@@ -42,7 +42,7 @@ func Acquire(path string) error { ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment