Skip to content
Merged
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
8 changes: 4 additions & 4 deletions lio/include/lio.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void lio_accept(struct lio_handle_t *lio, intptr_t fd, void (*callback)(intptr_t
* - `callback(result, buf, len)`: bytes sent (or negative errno), buffer
*
* # Safety
* `lio` must be valid; `buf` must be at least `buf_len` bytes allocated with
* `malloc`.
* `lio` must be valid; `buf` must point to at least `buf_len` bytes allocated
* with `malloc`.
*/
void lio_send(struct lio_handle_t *lio,
intptr_t fd,
Expand All @@ -195,8 +195,8 @@ void lio_send(struct lio_handle_t *lio,
* - `callback(result, buf, len)`: bytes received (or negative errno), buffer
*
* # Safety
* `lio` must be valid; `buf` must be at least `buf_len` bytes allocated with
* `malloc`.
* `lio` must be valid; `buf` must be a live buffer previously allocated by
* [`lio_buf_alloc(buf_len)`].
*/
void lio_recv(struct lio_handle_t *lio,
intptr_t fd,
Expand Down
2 changes: 2 additions & 0 deletions lio/src/api/ops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unnecessary_lazy_evaluations)]

//! I/O operation definitions.
//!
//! This module contains all the typed operation structs that implement `TypedOp`.
Expand Down
18 changes: 15 additions & 3 deletions lio/src/backend/ds.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#![allow(
clippy::large_enum_variant,
clippy::question_mark,
clippy::undocumented_unsafe_blocks,
clippy::unnecessary_cast,
clippy::unnecessary_map_or,
clippy::collapsible_if
)]

//! Deterministic simulation backend for higher-level tests.
//!
//! `DSBackend` never calls into the operating system. Instead it executes
Expand Down Expand Up @@ -2773,7 +2782,9 @@ impl DST {
}
self.poll_pending_node(to.node_id);
}
DSTEvent::DatagramDelivered { from, from_addr, to, packet, .. } => {
DSTEvent::DatagramDelivered {
from, from_addr, to, packet, ..
} => {
if !self
.inner
.borrow_mut()
Expand Down Expand Up @@ -3383,8 +3394,9 @@ impl DSTBackend {
let mut inner = self.inner.borrow_mut();
let ready_at_tick =
inner.tick + inner.event_delay_ticks_for(self.node_id, source_seq, 2);
let from_addr = bound
.unwrap_or_else(|| Self::synthetic_peer_addr(domain, self.node_id, raw));
let from_addr = bound.unwrap_or_else(|| {
Self::synthetic_peer_addr(domain, self.node_id, raw)
});
inner.enqueue_event(DSTEvent::DatagramDelivered {
ready_at_tick,
source_node: self.node_id,
Expand Down
8 changes: 4 additions & 4 deletions lio/src/backend/impls/io_uring.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::undocumented_unsafe_blocks)]

//! `lio`-provided [`IoBackend`] impl for `io_uring`.

use std::io;
Expand Down Expand Up @@ -342,10 +344,8 @@ impl LoweredState {
let state = unsafe { state.as_ref() };
if let (Some(out), Some((storage, len))) =
(state.from_out, state.addr.as_ref())
&& let Ok(addr) = crate::backend::op::socket_addr_buf_from_storage(
storage,
*len,
)
&& let Ok(addr) =
crate::backend::op::socket_addr_buf_from_storage(storage, *len)
{
unsafe {
*out.as_ptr() = addr;
Expand Down
2 changes: 2 additions & 0 deletions lio/src/backend/impls/pollingv2/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::undocumented_unsafe_blocks)]

//! `lio`-provided [`IoBackend`] impl for `epoll`/`kqueue` (platform-specific).

mod os;
Expand Down
2 changes: 2 additions & 0 deletions lio/src/backend/impls/pollingv2/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unnecessary_safety_comment)]

use super::{Interest, ReadinessPoll};
use std::io;
use std::os::fd::{AsRawFd, RawFd};
Expand Down
15 changes: 3 additions & 12 deletions lio/src/backend/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,7 @@ impl MsgRecv {
}

#[inline]
pub fn with_from(
bufs: &[MsgBufMut],
from: NonNull<SocketAddrBuf>,
) -> Self {
pub fn with_from(bufs: &[MsgBufMut], from: NonNull<SocketAddrBuf>) -> Self {
let mut msg = Self::new(bufs);
msg.from = Some(from);
msg
Expand Down Expand Up @@ -699,14 +696,8 @@ impl FileStat {

#[derive(Clone, Debug)]
pub enum StatTarget {
Path {
dir_fd: Resource,
path: NonNull<c_char>,
follow_symlinks: bool,
},
Fd {
fd: Resource,
},
Path { dir_fd: Resource, path: NonNull<c_char>, follow_symlinks: bool },
Fd { fd: Resource },
}

#[cfg(all(feature = "backend_impls", unix))]
Expand Down
2 changes: 1 addition & 1 deletion lio/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ pub unsafe extern "C" fn lio_sendto(
// SAFETY: caller guarantees fd is valid per fn contract
let resource = unsafe { fd_to_borrowed_resource(fd) };
// SAFETY: caller guarantees lio is valid per fn contract
crate::api::io::Io::from_op(api::Send::new(
crate::api::io::Io::from_op(api::ops::Send::new(
resource.clone(),
vec,
Some(socket_addr),
Expand Down
2 changes: 2 additions & 0 deletions lio/src/fs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::never_loop)]

//! Filesystem resource types.

use std::{
Expand Down
2 changes: 2 additions & 0 deletions lio/src/net/socket.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::undocumented_unsafe_blocks)]

use std::net::SocketAddr;

use crate::{
Expand Down
1 change: 1 addition & 0 deletions lio/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ impl Drop for TempFile {

/// Poll the lio event loop until a result is received on the channel.
/// Blocks in kqueue/epoll for up to 5ms per iteration — no busy-spin, no attempt cap.
#[allow(dead_code)]
pub fn poll_until_recv<T>(lio: &mut Lio, receiver: &mpsc::Receiver<T>) -> T {
{
for _ in 0..1_000 {
Expand Down
23 changes: 19 additions & 4 deletions lio/tests/net_socket_datagram.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![cfg(feature = "high")]

use std::{cell::RefCell, net::SocketAddr, rc::Rc};
Expand All @@ -13,15 +14,22 @@ struct ReceiverNode {
socket_rx: Option<Receiver<std::io::Result<Socket>>>,
socket: Option<Socket>,
bind_rx: Option<Receiver<std::io::Result<()>>>,
recv_rx: Option<Receiver<(std::io::Result<i32>, Vec<u8>, Option<SocketAddr>)>>,
recv_rx:
Option<Receiver<(std::io::Result<i32>, Vec<u8>, Option<SocketAddr>)>>,
recv_done: Rc<RefCell<Option<(Vec<u8>, Option<SocketAddr>)>>>,
}

impl ReceiverNode {
fn new(
recv_done: Rc<RefCell<Option<(Vec<u8>, Option<SocketAddr>)>>>,
) -> Self {
Self { socket_rx: None, socket: None, bind_rx: None, recv_rx: None, recv_done }
Self {
socket_rx: None,
socket: None,
bind_rx: None,
recv_rx: None,
recv_done,
}
}

fn drive(&mut self, bind_addr: SocketAddr) {
Expand Down Expand Up @@ -80,7 +88,13 @@ struct SenderNode {

impl SenderNode {
fn new(send_done: Rc<RefCell<bool>>) -> Self {
Self { socket_rx: None, socket: None, bind_rx: None, send_rx: None, send_done }
Self {
socket_rx: None,
socket: None,
bind_rx: None,
send_rx: None,
send_done,
}
}

fn drive(&mut self, bind_addr: SocketAddr, peer_addr: SocketAddr) {
Expand Down Expand Up @@ -119,7 +133,8 @@ impl SenderNode {
self.send_rx = Some(socket.sendto(b"ping".to_vec(), peer_addr).send());
}

if let Some((result, buf)) = self.send_rx.as_mut().and_then(Receiver::try_recv)
if let Some((result, buf)) =
self.send_rx.as_mut().and_then(Receiver::try_recv)
{
assert_eq!(result.unwrap(), buf.len() as i32);
*self.send_done.borrow_mut() = true;
Expand Down
4 changes: 3 additions & 1 deletion lio/tests/net_udp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
#![cfg(feature = "high")]

use std::{cell::RefCell, net::SocketAddr, rc::Rc};
Expand Down Expand Up @@ -53,7 +54,8 @@ impl ReceiverNode {
struct DatagramReceiverNode {
socket_rx: Option<Receiver<std::io::Result<UdpSocket>>>,
socket: Option<UdpSocket>,
recv_rx: Option<Receiver<(std::io::Result<i32>, Vec<u8>, Option<SocketAddr>)>>,
recv_rx:
Option<Receiver<(std::io::Result<i32>, Vec<u8>, Option<SocketAddr>)>>,
recv_done: Rc<RefCell<Option<(Vec<u8>, Option<SocketAddr>)>>>,
}

Expand Down
3 changes: 3 additions & 0 deletions lio/tests/ops.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod ops {
mod accept;
mod bind;
mod common;
mod connect;
mod getcwd;
mod interval;
mod linkat;
mod listen;
mod mkdirat;
mod openat;
mod readdir;
Expand All @@ -15,6 +17,7 @@ mod ops {
mod rw;
mod send;
mod sendto;
mod shutdown;
mod sleep;
mod socket;
#[cfg(unix)]
Expand Down
Loading