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
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.