Skip to content

Commit

Permalink
fix(fs,net,signal): check driver type on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Dec 2, 2024
1 parent c59a0fd commit 79d4d33
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compio-fs/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ async fn is_fifo(file: &File) -> io::Result<bool> {

/// Sets file's flags with O_NONBLOCK by fcntl.
fn set_nonblocking(file: &impl AsRawFd) -> io::Result<()> {
if cfg!(not(all(target_os = "linux", feature = "io-uring"))) {
if compio_driver::DriverType::is_polling() {
let fd = file.as_raw_fd();
let current_flags = syscall!(libc::fcntl(fd, libc::F_GETFL))?;
let flags = current_flags | libc::O_NONBLOCK;
Expand Down
10 changes: 2 additions & 8 deletions compio-net/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ impl Socket {
// non blocking socket when there is no connections in listen queue
//
// https://patchwork.kernel.org/project/linux-block/patch/[email protected]/#22949861
if cfg!(all(
unix,
not(all(target_os = "linux", feature = "io-uring"))
)) {
if compio_driver::DriverType::is_polling() {
socket.set_nonblocking(true)?;
}
}
Expand Down Expand Up @@ -164,10 +161,7 @@ impl Socket {
let BufResult(res, op) = compio_runtime::submit(op).await;
let addr = op.into_addr();
let accept_sock = unsafe { Socket2::from_raw_fd(res? as _) };
if cfg!(all(
unix,
not(all(target_os = "linux", feature = "io-uring"))
)) {
if compio_driver::DriverType::is_polling() {
accept_sock.set_nonblocking(true)?;
}
let accept_sock = Self::from_socket2(accept_sock)?;
Expand Down
2 changes: 1 addition & 1 deletion compio-signal/src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl SignalFd {
fn new(sig: i32) -> io::Result<Self> {
let set = register_signal(sig)?;
let mut flag = libc::SFD_CLOEXEC;
if cfg!(not(feature = "io-uring")) {
if compio_driver::DriverType::is_polling() {
flag |= libc::SFD_NONBLOCK;
}
let fd = syscall!(libc::signalfd(-1, &set, flag))?;
Expand Down

0 comments on commit 79d4d33

Please sign in to comment.