-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 Use non blocking file locking for flock library #1605
Conversation
aea8d8e
to
ef91bc3
Compare
pkg/internal/flock/flock_unix.go
Outdated
return unix.Flock(fd, unix.LOCK_EX) | ||
err = unix.Flock(fd, unix.LOCK_NB|unix.LOCK_EX) | ||
if errors.Is(err, unix.EWOULDBLOCK) { // This condition requires LOCK_NB. | ||
return errors.Wrapf(ErrAlreadyLocked, "cannot lock file %q", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, can we just use the stdlib wrapping (fmt.Errorf("cannot lock file %q: %w", path, err)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Errorf wouldn't wrap things properly, and we can't use errors.Is
on the other side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err what? If you wrap using fmt.Errorf("%w", err)
, errors.Is
should absolutely work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I didn't know that was the case, fixed.
965003c
to
c439bb6
Compare
Signed-off-by: Vince Prignano <vincepri@vmware.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Vince Prignano vincepri@vmware.com
Fixes #1599