Add Solaris fcntl file locking#17110
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| pub enum LockKind { | ||
| Exclusive, | ||
| Shared, | ||
| } |
There was a problem hiding this comment.
Just a minor nit, is there a reason to duplicate this LockKind enum in each imp? That is, could it be lifted out?
Or, maybe a more general question, why was this added? At a glance, it seems like if each imp had the separate functions for exclusive and shared without the kind (and remove the functions in the parent module), that would simplify this and have fewer lines overall.
There was a problem hiding this comment.
Good point. I originally used LockKind to keep the Solaris fcntl path centralized, since shared and exclusive locks only differ by the raw lock type.
I simplified this now: each backend exposes explicit shared/exclusive functions, and the Solaris backend keeps only a private helper that takes the raw fcntl lock type. That removes the duplicated enum and the parent wrapper functions while keeping the behavior unchanged.
Rust std no longer provides File::lock support on Solaris because its fcntl emulation is process-scoped rather than handle-scoped. Keep Cargo's inter-process locking working on Solaris by routing Cargo's FileLock abstraction through a Solaris-specific fcntl backend. Use whole-file advisory locks for shared, exclusive, nonblocking, blocking, and unlock operations, while leaving other platforms on std::fs::File locking. Mark the same-process cache-lock tests ignored on Solaris because fcntl locks are process-scoped and those tests do not model separate Cargo processes.
040c704 to
5fe7a28
Compare
Pull request was closed
There was a problem hiding this comment.
FWIW, this -Zfine-grain-locking branch also needs a patch. Not blocking though.
cargo/src/cargo/core/compiler/locking.rs
Line 88 in d3b55f8
### What does this PR try to resolve? Address the last missing part in `-Zfine-grain-locking`: rust-lang/cargo#17110 (review) Resolves rust-lang/cargo#17084 ### How to test and review this PR? r? ehuss
Update cargo submodules 6 commits in a595d0da21f228b7fdae64d3d5c0e527ea66bb59..a335d47ff8036918d3d548dabd513dc0444096a9 2026-06-20 13:42:59 +0000 to 2026-06-26 20:39:41 +0000 - fix(diag): Remove sometimes-invalid removal suggestions (rust-lang/cargo#17139) - feat: Add `-Zhint-msrv` flag (rust-lang/cargo#17106) - fix: LockManager use OS-aware flock shim (rust-lang/cargo#17128) - fix: flaky test: sparse_blocking_count (rust-lang/cargo#17130) - Add Solaris fcntl file locking (rust-lang/cargo#17110) - fix(test): skip dwp uplift test without packed debuginfo (rust-lang/cargo#17127) r? ghost
Update cargo submodules 6 commits in a595d0da21f228b7fdae64d3d5c0e527ea66bb59..a335d47ff8036918d3d548dabd513dc0444096a9 2026-06-20 13:42:59 +0000 to 2026-06-26 20:39:41 +0000 - fix(diag): Remove sometimes-invalid removal suggestions (rust-lang/cargo#17139) - feat: Add `-Zhint-msrv` flag (rust-lang/cargo#17106) - fix: LockManager use OS-aware flock shim (rust-lang/cargo#17128) - fix: flaky test: sparse_blocking_count (rust-lang/cargo#17130) - Add Solaris fcntl file locking (rust-lang/cargo#17110) - fix(test): skip dwp uplift test without packed debuginfo (rust-lang/cargo#17127) r? ghost
Update cargo submodules 6 commits in a595d0da21f228b7fdae64d3d5c0e527ea66bb59..a335d47ff8036918d3d548dabd513dc0444096a9 2026-06-20 13:42:59 +0000 to 2026-06-26 20:39:41 +0000 - fix(diag): Remove sometimes-invalid removal suggestions (rust-lang/cargo#17139) - feat: Add `-Zhint-msrv` flag (rust-lang/cargo#17106) - fix: LockManager use OS-aware flock shim (rust-lang/cargo#17128) - fix: flaky test: sparse_blocking_count (rust-lang/cargo#17130) - Add Solaris fcntl file locking (rust-lang/cargo#17110) - fix(test): skip dwp uplift test without packed debuginfo (rust-lang/cargo#17127) r? ghost
Update cargo submodules 6 commits in a595d0da21f228b7fdae64d3d5c0e527ea66bb59..a335d47ff8036918d3d548dabd513dc0444096a9 2026-06-20 13:42:59 +0000 to 2026-06-26 20:39:41 +0000 - fix(diag): Remove sometimes-invalid removal suggestions (rust-lang/cargo#17139) - feat: Add `-Zhint-msrv` flag (rust-lang/cargo#17106) - fix: LockManager use OS-aware flock shim (rust-lang/cargo#17128) - fix: flaky test: sparse_blocking_count (rust-lang/cargo#17130) - Add Solaris fcntl file locking (rust-lang/cargo#17110) - fix(test): skip dwp uplift test without packed debuginfo (rust-lang/cargo#17127) r? ghost
Update cargo submodules 6 commits in a595d0da21f228b7fdae64d3d5c0e527ea66bb59..a335d47ff8036918d3d548dabd513dc0444096a9 2026-06-20 13:42:59 +0000 to 2026-06-26 20:39:41 +0000 - fix(diag): Remove sometimes-invalid removal suggestions (rust-lang/cargo#17139) - feat: Add `-Zhint-msrv` flag (rust-lang/cargo#17106) - fix: LockManager use OS-aware flock shim (rust-lang/cargo#17128) - fix: flaky test: sparse_blocking_count (rust-lang/cargo#17130) - Add Solaris fcntl file locking (rust-lang/cargo#17110) - fix(test): skip dwp uplift test without packed debuginfo (rust-lang/cargo#17127) r? ghost
Rust std no longer provides File::lock support on Solaris because its fcntl emulation is process-scoped rather than handle-scoped. Keep Cargo's inter-process locking working on Solaris by routing Cargo's FileLock abstraction through a Solaris-specific fcntl backend.
Use whole-file advisory locks for shared, exclusive, nonblocking, blocking, and unlock operations, while leaving other platforms on std::fs::File locking. Mark the same-process cache-lock tests ignored on Solaris because fcntl locks are process-scoped and those tests do not model separate Cargo processes.