-
Notifications
You must be signed in to change notification settings - Fork 8
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build on Plan 9 #17
Conversation
Plan 9 doesn't have syscall.EAGAIN. Copy some code from Go's internal locakedfile package to check whether the file is locked by another process.
Thank you for submitting this PR!
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. |
// - "exclusive use file already open" (ramfs) | ||
// | ||
// See https://github.com/golang/go/blob/go1.15rc1/src/cmd/go/internal/lockedfile/lockedfile_plan9.go#L16 | ||
var lockedErrStrings = [...]string{ |
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.
Agree that the structure you've added here seems like a reasonable way to extend the lock function to plan9, and this follows the definitions in the standard library, so seems fine.
The one semantic thing I'm not clear on that is worth checking if you haven't yet, is that these errors will cover both the "someone else has the lock" error that they will trigger the overall Lock
method returning, and the lock is already held by us
case in the main lock switch statement.
I haven't looked to see if any of the callers of Lock
do different things based on those errors, and my quick read at how plan9 is structuring its errors doesn't leave me overly optimistic that we'd be able to efficiently learn if the existing exclusive fid is in the same process, but it's probably worth checking to make sure there isn't code that's using those semantics.
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.
If the lock is held by us, we get this error:
file "/tmp/filelock/my-test.lock" already locked
If the lock is held by another process, we get this error:
cannot acquire lock: Lock Create of /tmp/filelock/my-test.lock failed: open /tmp/filelock/my-test.lock: '/tmp/filelock/my-test.lock' file is locked
I think I already distinguish between these two errors by checking if the error string contains "Lock Create of" (similar to isLockCreatePermFail
function). We depends on go4.org/lock
returning two kinds of errors, but I think it's good enough solution.
Plan 9 doesn't have syscall.EAGAIN. Copy some code from Go's internal
locakedfile package to check whether the file is locked by another
process.