-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implements cargo file locking using fcntl on Solaris. #11439
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
src/cargo/util/flock.rs
Outdated
if (flag & libc::LOCK_SH) != 0 { | ||
flock.l_type |= libc::F_RDLCK; | ||
} | ||
if (flag & libc::LOCK_EX) != 0 { | ||
flock.l_type |= libc::F_WRLCK; | ||
} | ||
if (flag & libc::LOCK_UN) != 0 { | ||
flock.l_type |= libc::F_UNLCK; | ||
} |
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.
I don't think l_type is a bitmask. That is, F_RDLCK|F_WRLCK would result in 3 (F_UNLCK). Should this be =
instead? That is, something like:
flock.l_type = if flag & libc::LOCK_UN != 0 { libc::F_RDLCK }
else if flag & libc::LOCK_EX != 0 { libc::F_WRLCK }
else if flag & libc::LOCK_SH != 0 { libc::F_RDLCK }
else { panic!("…") };
Although here those flags won't get set simultaneously, I think it looks a little strange to use bitwise-or for something that is not a bitmask.
Thanks! I don't have access to a Solaris system handy, so I can test this, but it seems like it should be correct to me. @bors r+ |
☀️ Test successful - checks-actions |
2 commits in f6e737b1e3386adb89333bf06a01f68a91ac5306..70898e522116f6c23971e2a554b2dc85fd4c84cd 2022-12-02 20:21:24 +0000 to 2022-12-05 19:43:44 +0000 - Rename `generate_units` -> `generate_root_units` (rust-lang/cargo#11458) - Implements cargo file locking using fcntl on Solaris. (rust-lang/cargo#11439)
Update cargo 2 commits in f6e737b1e3386adb89333bf06a01f68a91ac5306..70898e522116f6c23971e2a554b2dc85fd4c84cd 2022-12-02 20:21:24 +0000 to 2022-12-05 19:43:44 +0000 - Rename `generate_units` -> `generate_root_units` (rust-lang/cargo#11458) - Implements cargo file locking using fcntl on Solaris. (rust-lang/cargo#11439) r? `@ghost`
l_pad: [0, 0, 0, 0], | ||
}; | ||
flock.l_type = if flag & libc::LOCK_UN != 0 { | ||
libc::F_RDLCK |
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.
Shouldn't this be F_UNLCK
?
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.
Oh my, I didn't catch that. @psumbera can you follow up with a PR to update this?
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.
I will fix it. Sorry I didn't catch that. Since I have tested it this doesn't cause the problem with use in cargo.
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.
Fixes #11421.