Skip to content

Commit

Permalink
fix error code to be POSIX compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Sep 29, 2024
1 parent 58cb8b0 commit 94f29be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ pub(crate) trait ObjectInterface: Sync + Send + core::fmt::Debug {
/// `setsockopt` sets options on sockets
#[cfg(any(feature = "tcp", feature = "udp", feature = "vsock"))]
async fn setsockopt(&self, _opt: SocketOption, _optval: bool) -> io::Result<()> {
Err(io::Error::EINVAL)
Err(io::Error::ENOTSOCK)
}

/// `getsockopt` gets options on sockets
#[cfg(any(feature = "tcp", feature = "udp", feature = "vsock"))]
async fn getsockopt(&self, _opt: SocketOption) -> io::Result<bool> {
Err(io::Error::EINVAL)
Err(io::Error::ENOTSOCK)
}

/// `getsockname` gets socket name
Expand Down
1 change: 1 addition & 0 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub enum Error {
EEXIST = crate::errno::EEXIST as isize,
EADDRINUSE = crate::errno::EADDRINUSE as isize,
EOVERFLOW = crate::errno::EOVERFLOW as isize,
ENOTSOCK = crate::errno::ENOTSOCK as isize,
}

pub type Result<T> = result::Result<T, Error>;
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl PerCoreScheduler {
let mut pinned_obj = core::pin::pin!(borrowed.object_map.read());

let guard = ready!(pinned_obj.as_mut().poll(cx));
Ready(guard.get(&fd).cloned().ok_or(io::Error::EINVAL))
Ready(guard.get(&fd).cloned().ok_or(io::Error::EBADF))
})
})
.await
Expand Down Expand Up @@ -579,7 +579,7 @@ impl PerCoreScheduler {
let borrowed = self.current_task.borrow();
let mut pinned_obj = core::pin::pin!(borrowed.object_map.write());
let mut guard = ready!(pinned_obj.as_mut().poll(cx));
Ready(guard.remove(&fd).ok_or(io::Error::EINVAL))
Ready(guard.remove(&fd).ok_or(io::Error::EBADF))
})
})
.await
Expand Down

0 comments on commit 94f29be

Please sign in to comment.