-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an `fcntl_lock` function implementing fcntl-style process-associated locking. Currently this only supports locking the entire file.
- Loading branch information
1 parent
b855bd0
commit 5390d82
Showing
10 changed files
with
160 additions
and
7 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
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
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
File renamed without changes.
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
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,33 @@ | ||
#[test] | ||
fn test_fcntl_lock() { | ||
use rustix::fs::{fcntl_lock, FlockOperation}; | ||
|
||
let f = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&f, FlockOperation::LockExclusive).unwrap(); | ||
fcntl_lock(&f, FlockOperation::Unlock).unwrap(); | ||
let g = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&g, FlockOperation::LockExclusive).unwrap(); | ||
fcntl_lock(&g, FlockOperation::Unlock).unwrap(); | ||
drop(f); | ||
drop(g); | ||
|
||
let f = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&f, FlockOperation::LockShared).unwrap(); | ||
let g = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&g, FlockOperation::LockShared).unwrap(); | ||
fcntl_lock(&f, FlockOperation::Unlock).unwrap(); | ||
fcntl_lock(&g, FlockOperation::Unlock).unwrap(); | ||
drop(f); | ||
drop(g); | ||
|
||
let f = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&f, FlockOperation::LockShared).unwrap(); | ||
fcntl_lock(&f, FlockOperation::LockExclusive).unwrap(); | ||
fcntl_lock(&f, FlockOperation::Unlock).unwrap(); | ||
let g = tempfile::tempfile().unwrap(); | ||
fcntl_lock(&g, FlockOperation::LockShared).unwrap(); | ||
fcntl_lock(&g, FlockOperation::LockExclusive).unwrap(); | ||
fcntl_lock(&g, FlockOperation::Unlock).unwrap(); | ||
drop(f); | ||
drop(g); | ||
} |
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