-
Notifications
You must be signed in to change notification settings - Fork 385
Support F_GETFL and F_SETFL for fcntl #4212
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
Open
tiif
wants to merge
26
commits into
rust-lang:master
Choose a base branch
from
tiif:setfl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f46aff7
Add F_SETFL flag
tiif 90d26c9
Add SETFL
tiif 300b03f
Add basic test for setfl
tiif 0c21392
Add test for threaded setfl
tiif 1175ee9
Add comment to test
tiif 3d64a90
Fix the blocking test
tiif 37b5f7f
Add a FIXME
tiif e9a89bd
Shift comment to the right place
tiif 5340930
Remove spurious change
tiif 1b016be
macos don't have SOCK_NONBLOCK
tiif c77e35c
Fix typo in error message
tiif 972b56f
Add comment for is_nonblock field in AnonSocket
tiif a9eec52
Inline cmd_name and fix typo
tiif 269ffb7
Remove comment for O_NONBLOCK == SOCK_NONBLOCK
tiif 98a5d80
Modify test to use one thread
tiif aded1b1
Move all test to use isolation mode
tiif 40ccdf3
Add set_flags and get_flags to fd method, and add an enum to differen…
tiif b0930af
Properly implement set_flag and get_flag
tiif 5eac6c2
Add test for socketpair
tiif 4b223b7
Add basic test for pipe
tiif 6a81eb1
Fix the anonsocket fd name
tiif e86f92f
fmt
tiif 3c76582
Add unsetting test
tiif a7ed890
Fix comment
tiif aad9ce6
Move test to individual function
tiif 2b17578
Fix clippy error
tiif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,21 @@ | ||
//@ignore-target: windows # File handling is not implemented yet | ||
//~^ ERROR: deadlock: the evaluated program deadlocked | ||
//@compile-flags: -Zmiri-preemption-rate=0 | ||
use std::thread; | ||
|
||
/// If an O_NONBLOCK flag is set while the fd is blocking, that fd will not be woken up. | ||
fn main() { | ||
let mut fds = [-1, -1]; | ||
let res = unsafe { libc::pipe(fds.as_mut_ptr()) }; | ||
assert_eq!(res, 0); | ||
let mut buf: [u8; 5] = [0; 5]; | ||
let _thread1 = thread::spawn(move || { | ||
// Add O_NONBLOCK flag while pipe is still block on read. | ||
let new_flag = libc::O_NONBLOCK; | ||
let res = unsafe { libc::fcntl(fds[0], libc::F_SETFL, new_flag) }; | ||
assert_eq!(res, 0); | ||
}); | ||
// Main thread will block on read. | ||
let _res = unsafe { libc::read(fds[0], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) }; | ||
//~^ ERROR: deadlock: the evaluated program deadlocked | ||
} |
This file contains hidden or 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,19 @@ | ||
error: deadlock: the evaluated program deadlocked | ||
| | ||
= note: the evaluated program deadlocked | ||
= note: (no span available) | ||
= note: BACKTRACE on thread `unnamed-ID`: | ||
|
||
error: deadlock: the evaluated program deadlocked | ||
--> tests/fail-dep/libc/fcntl_fsetfl_while_blocking.rs:LL:CC | ||
| | ||
LL | let _res = unsafe { libc::read(fds[0], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) }; | ||
| ^ the evaluated program deadlocked | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `main` at tests/fail-dep/libc/fcntl_fsetfl_while_blocking.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 2 previous errors | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.