-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
`fcntl` man page says that: > F_SETPIPE_SZ ... The actual capacity (in bytes) that is set is > returned as the function result. But the current `fcntl_setpipe_size` function assumes that the return value is 0 (success) or negative (failure). This makes the function panic due to `debug_assert!` in debug mode, and it returns `Err` on success in release mode. This commit fixes the return value type and its checking, and adds a test for it.
- Loading branch information
Showing
5 changed files
with
38 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
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,31 @@ | ||
#[cfg(linux_kernel)] | ||
#[test] | ||
fn test_fcntl_getpipe_size() { | ||
use rustix::pipe::fcntl_getpipe_size; | ||
|
||
let (reader, writer) = rustix::pipe::pipe().unwrap(); | ||
|
||
let reader_size = fcntl_getpipe_size(&reader).unwrap(); | ||
let writer_size = fcntl_getpipe_size(&writer).unwrap(); | ||
assert_eq!(reader_size, writer_size); | ||
} | ||
|
||
#[cfg(linux_kernel)] | ||
#[test] | ||
fn test_fcntl_setpipe_size() { | ||
use rustix::pipe::{fcntl_getpipe_size, fcntl_setpipe_size}; | ||
|
||
let (reader, writer) = rustix::pipe::pipe().unwrap(); | ||
|
||
let new_size = 4096 * 2; | ||
let reader_size = fcntl_setpipe_size(&reader, new_size).unwrap(); | ||
let writer_size = fcntl_getpipe_size(&writer).unwrap(); | ||
assert_eq!(reader_size, new_size); | ||
assert_eq!(reader_size, writer_size); | ||
|
||
let new_size = 4096 * 16; | ||
let reader_size = fcntl_setpipe_size(&reader, new_size).unwrap(); | ||
let writer_size = fcntl_getpipe_size(&writer).unwrap(); | ||
assert_eq!(reader_size, new_size); | ||
assert_eq!(reader_size, writer_size); | ||
} |
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 |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
#![cfg(not(windows))] | ||
|
||
mod basic; | ||
mod fcntl; | ||
mod splice; | ||
mod tee; |