-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
Flock
object for automatic unlock on drop. (#2170)
* Added object for automatic unlock on drop. * Added appropriate changelog file. * Fixed doc error on `Flock`. * Requested changes to make `fcntl::flock` private and OwnedFd instead of RawFd. * Indent fix. * Removed doc links to private item, updated imports. * More import fixes. * Format changes. * Remove unused import for redox. * Added `Flockable` trait per discussions, added tests for `Flock`. * Simplified flock error conditionals. * Added missing cfg flags for `Flockable`. * Added missing cfg flags for impl of `Flockable` on `File`. * Update src/fcntl.rs Co-authored-by: SteveLauC <stevelauc@outlook.com> * Updated `Flockable` comment per suggestion. * Finalized `FlockArg` as enum and removed TODO accordingly, removed flock wrapper entirely. * Implemented `Flockable` for `OwnedFd` as well. * Fixed linting error. * Updated changelog accordingly. * Corrected errno logic in `Flock::lock`. * Properly dropped inner type for `Flock`. * Replaced `ManuallyDrop` with `Option` as inner `Flock` type to avoid double-free. * Fixed linting errors. * Removed unnecessary cfg condition, updated documentation. * Modified Flock behavior for drop() and unlock(). * Reverted changes to original `flock()` and `FlockArg` for deprecation period, added EINVAL case if the unlock operation is given to `Flock::lock()`. * Refactored `Flock` to wrap T directly and avoid a double-free after `unlock()` is used. * Fixed linting errors. * More linting fixes. * Fixed example code for `Flock::unlock()`. * Made requested changes. * Removed duplicate import. * Format change. --------- Co-authored-by: SteveLauC <stevelauc@outlook.com>
- Loading branch information
1 parent
2ad5573
commit 9b39cf9
Showing
3 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Added newtype `Flock` to automatically unlock a held flock upon drop. | ||
Added `Flockable` trait to represent valid types for `Flock`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters