the lockfile should be handled after function return

This commit is contained in:
guangxuli 2016-09-13 16:15:42 +08:00
parent ba3ab80b09
commit 05d0c720f1

View File

@ -42,7 +42,7 @@ func Acquire(path string) error {
if lockfile, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600); err != nil {
return err
}
defer lockfile.Close()
opts := unix.Flock_t{Type: unix.F_WRLCK}
if err := unix.FcntlFlock(lockfile.Fd(), unix.F_SETLKW, &opts); err != nil {
return err