Skip to content

Commit

Permalink
fix missing read-write flag in reopenFDOnError
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Jul 22, 2024
1 parent ffdd9d4 commit b5eb65b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flock_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package flock

import (
"errors"
"os"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -198,11 +199,12 @@ func (f *Flock) reopenFDOnError(err error) (bool, error) {

f.resetFh()

// reopen the file handle
err = f.setFh()
// reopen in read-write mode and set the file handle
fh, err := os.OpenFile(f.path, f.flag|os.O_RDWR, f.perm)
if err != nil {
return false, err
}
f.fh = fh

return true, nil
}

0 comments on commit b5eb65b

Please sign in to comment.