Skip to content

Commit bf38b98

Browse files
authored
Merge pull request #63 from rust-vsock/dependabot/cargo/nix-0.31.2
Update nix requirement from 0.30.1 to 0.31.2
2 parents 10ec085 + 63b3af1 commit bf38b98

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ edition = "2021"
1111
exclude = ["test_fixture"]
1212

1313
[dependencies]
14-
libc = "0.2.158"
15-
nix = { version = "0.30.1", features = ["ioctl", "socket"] }
14+
libc = "0.2.182"
15+
nix = { version = "0.31.2", features = ["ioctl", "socket"] }
1616

1717
[dev-dependencies]
1818
rand = "0.9.0"

src/lib.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@
1818
//! Virtio socket support for Rust.
1919
2020
use libc::{
21-
accept, fcntl, ioctl, sa_family_t, sockaddr, sockaddr_vm, socklen_t, suseconds_t, timeval,
22-
AF_VSOCK, FD_CLOEXEC, FIONBIO, F_SETFD,
21+
accept, fcntl, ioctl, sa_family_t, sockaddr, sockaddr_vm, socklen_t, timeval, AF_VSOCK,
22+
FD_CLOEXEC, FIONBIO, F_SETFD,
2323
};
2424
use nix::{
2525
ioctl_read_bad,
26-
sys::socket::{
27-
self, bind, connect, getpeername, getsockname, listen, recv, recvfrom, send, sendto,
28-
shutdown, socket,
29-
sockopt::{ReceiveTimeout, SendTimeout, SocketError},
30-
AddressFamily, Backlog, GetSockOpt, MsgFlags, SetSockOpt, SockFlag, SockType,
26+
sys::{
27+
socket::{
28+
self, bind, connect, getpeername, getsockname, listen, recv, recvfrom, send, sendto,
29+
shutdown, socket,
30+
sockopt::{ReceiveTimeout, SendTimeout, SocketError},
31+
AddressFamily, Backlog, GetSockOpt, MsgFlags, SetSockOpt, SockFlag, SockType,
32+
},
33+
time::TimeVal,
3134
},
3235
unistd::close,
3336
};
@@ -62,8 +65,8 @@ fn default_send_msg_flags() -> MsgFlags {
6265
flags
6366
}
6467

65-
/// Internal helper to turn a [`Duration`] into a [`timeval`]
66-
fn timeval_from_duration(dur: Option<Duration>) -> Result<timeval> {
68+
/// Internal helper to turn a [`Duration`] into a [`TimeVal`].
69+
fn timeval_from_duration(dur: Option<Duration>) -> Result<TimeVal> {
6770
match dur {
6871
Some(dur) => {
6972
if dur.as_secs() == 0 && dur.subsec_nanos() == 0 {
@@ -80,19 +83,17 @@ fn timeval_from_duration(dur: Option<Duration>) -> Result<timeval> {
8083
} else {
8184
dur.as_secs() as libc::time_t
8285
};
86+
#[cfg_attr(target_env = "musl", allow(deprecated))]
8387
let mut timeout = timeval {
8488
tv_sec: secs,
85-
tv_usec: i64::from(dur.subsec_micros()) as suseconds_t,
89+
tv_usec: i64::from(dur.subsec_micros()) as libc::suseconds_t,
8690
};
8791
if timeout.tv_sec == 0 && timeout.tv_usec == 0 {
8892
timeout.tv_usec = 1;
8993
}
90-
Ok(timeout)
94+
Ok(timeout.into())
9195
}
92-
None => Ok(timeval {
93-
tv_sec: 0,
94-
tv_usec: 0,
95-
}),
96+
None => Ok(TimeVal::new(0, 0)),
9697
}
9798
}
9899

@@ -311,13 +312,13 @@ impl VsockSocket {
311312

312313
/// Set the timeout on read operations.
313314
pub fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()> {
314-
let timeout = timeval_from_duration(dur)?.into();
315+
let timeout = timeval_from_duration(dur)?;
315316
Ok(ReceiveTimeout.set(&self.socket, &timeout)?)
316317
}
317318

318319
/// Set the timeout on write operations.
319320
pub fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()> {
320-
let timeout = timeval_from_duration(dur)?.into();
321+
let timeout = timeval_from_duration(dur)?;
321322
Ok(SendTimeout.set(&self.socket, &timeout)?)
322323
}
323324

@@ -460,13 +461,13 @@ impl VsockStream {
460461

461462
/// Set the timeout on read operations.
462463
pub fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()> {
463-
let timeout = timeval_from_duration(dur)?.into();
464+
let timeout = timeval_from_duration(dur)?;
464465
Ok(ReceiveTimeout.set(&self.socket, &timeout)?)
465466
}
466467

467468
/// Set the timeout on write operations.
468469
pub fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()> {
469-
let timeout = timeval_from_duration(dur)?.into();
470+
let timeout = timeval_from_duration(dur)?;
470471
Ok(SendTimeout.set(&self.socket, &timeout)?)
471472
}
472473

0 commit comments

Comments
 (0)