Skip to content

General cleanup - update dependencies & remove broken/redundant tests #324

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
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ keywords = ["async", "fs", "io-uring"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.2", features = ["net", "rt", "sync"] }
tokio = { version = "1.43", features = ["net", "rt", "sync"] }
slab = "0.4.2"
libc = "0.2.80"
io-uring = "0.6.0"
socket2 = { version = "0.4.4", features = ["all"] }
io-uring = "0.7.4"
socket2 = { version = "0.5.8", features = ["all"] }
bytes = { version = "1.0", optional = true }
futures-util = { version = "0.3.26", default-features = false, features = ["std"] }

[dev-dependencies]
tempfile = "3.2.0"
tempfile = "3.17.0"
tokio-test = "0.4.2"
iai = "0.1.1"
criterion = "0.4.0"
criterion = "0.5.1"
# we use joinset in our tests
tokio = "1.21.2"
nix = "0.26.1"
nix = { version = "0.29.0", features = ["resource"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion src/io/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Completable for Accept {
let fd = SharedFd::new(fd as i32);
let socket = Socket { fd };
let (_, addr) = unsafe {
socket2::SockAddr::init(move |addr_storage, len| {
socket2::SockAddr::try_init(move |addr_storage, len| {
self.socketaddr.0.clone_into(&mut *addr_storage);
*len = self.socketaddr.1;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/io/recv_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<T: BoundedBufMut> Op<RecvFrom<T>> {
std::slice::from_raw_parts_mut(buf.stable_mut_ptr(), buf.bytes_total())
})];

let socket_addr = Box::new(unsafe { SockAddr::init(|_, _| Ok(()))?.1 });
let socket_addr = Box::new(unsafe { SockAddr::try_init(|_, _| Ok(()))?.1 });

let mut msghdr: Box<libc::msghdr> = Box::new(unsafe { std::mem::zeroed() });
msghdr.msg_iov = io_slices.as_mut_ptr().cast();
Expand Down
2 changes: 1 addition & 1 deletion src/io/recvmsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<T: BoundedBufMut> Op<RecvMsg<T>> {
}));
}

let socket_addr = Box::new(unsafe { SockAddr::init(|_, _| Ok(()))?.1 });
let socket_addr = Box::new(unsafe { SockAddr::try_init(|_, _| Ok(()))?.1 });

let mut msghdr: Box<libc::msghdr> = Box::new(unsafe { std::mem::zeroed() });
msghdr.msg_iov = io_slices.as_mut_ptr().cast();
Expand Down
10 changes: 9 additions & 1 deletion src/io/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use std::{
io,
net::SocketAddr,
os::unix::io::{AsRawFd, IntoRawFd, RawFd},
os::unix::io::{AsFd, AsRawFd, IntoRawFd, RawFd, BorrowedFd},
path::Path,
};

Expand Down Expand Up @@ -285,3 +285,11 @@ impl AsRawFd for Socket {
self.fd.raw_fd()
}
}

impl AsFd for Socket {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe {
BorrowedFd::borrow_raw(self.fd.raw_fd())
}
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
//! call `close()`.

#![warn(missing_docs)]
#![allow(clippy::thread_local_initializer_can_be_made_const)]
#![allow(clippy::missing_const_for_thread_local)]

macro_rules! syscall {
($fn: ident ( $($arg: expr),* $(,)* ) ) => {{
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/driver/op/slab_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a, T> SlabList<'a, T> {
}
}

impl<'a, T> Drop for SlabList<'a, T> {
impl<T> Drop for SlabList<'_, T> {
fn drop(&mut self) {
while !self.is_empty() {
let removed = self.slab.remove(self.index.start);
Expand All @@ -120,7 +120,7 @@ impl<'a, T> Drop for SlabList<'a, T> {
}
}

impl<'a, T> Iterator for SlabList<'a, T> {
impl<T> Iterator for SlabList<'_, T> {
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
40 changes: 0 additions & 40 deletions tests/fs_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,6 @@ fn cancel_read() {
});
}

#[test]
fn explicit_close() {
let mut tempfile = tempfile();
tempfile.write_all(HELLO).unwrap();

tokio_uring::start(async {
let file = File::open(tempfile.path()).await.unwrap();
let fd = file.as_raw_fd();

file.close().await.unwrap();

assert_invalid_fd(fd);
})
}

#[test]
fn drop_open() {
tokio_uring::start(async {
Expand All @@ -160,19 +145,6 @@ fn drop_open() {
});
}

#[test]
fn drop_off_runtime() {
let file = tokio_uring::start(async {
let tempfile = tempfile();
File::open(tempfile.path()).await.unwrap()
});

let fd = file.as_raw_fd();
drop(file);

assert_invalid_fd(fd);
}

#[test]
fn sync_doesnt_kill_anything() {
let tempfile = tempfile();
Expand Down Expand Up @@ -331,15 +303,3 @@ async fn poll_once(future: impl std::future::Future) {
})
.await;
}

fn assert_invalid_fd(fd: RawFd) {
use std::fs::File;

let mut f = unsafe { File::from_raw_fd(fd) };
let mut buf = vec![];

match f.read_to_end(&mut buf) {
Err(ref e) if e.raw_os_error() == Some(libc::EBADF) => {}
res => panic!("assert_invalid_fd finds for fd {:?}, res = {:?}", fd, res),
}
}