diff options
| author | David Carlier <devnexen@gmail.com> | 2025-04-29 19:01:08 +0100 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2025-09-26 18:39:29 +0100 |
| commit | c0de794949f652b368fa107c3b52d0515f1f3859 (patch) | |
| tree | 00043be4fa0d2db5642185e697da7728ab5e8741 /library/std/src/sys | |
| parent | e004014d1bf4c29928a0f0f9f7d0964d43606cbd (diff) | |
| download | rust-c0de794949f652b368fa107c3b52d0515f1f3859.tar.gz rust-c0de794949f652b368fa107c3b52d0515f1f3859.zip | |
std::net: update tcp deferaccept delay type to Duration.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/net/connection/socket/unix.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index 8b5970d1494..86b966242bf 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -485,14 +485,15 @@ impl Socket { // bionic libc makes no use of this flag #[cfg(target_os = "linux")] - pub fn set_deferaccept(&self, accept: u32) -> io::Result<()> { - setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, accept as c_int) + pub fn set_deferaccept(&self, accept: Duration) -> io::Result<()> { + let val = cmp::min(accept.as_secs(), c_int::MAX as u64) as c_int; + setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, val) } #[cfg(target_os = "linux")] - pub fn deferaccept(&self) -> io::Result<u32> { + pub fn deferaccept(&self) -> io::Result<Duration> { let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT)?; - Ok(raw as u32) + Ok(Duration::from_secs(raw as _)) } #[cfg(any(target_os = "freebsd", target_os = "netbsd"))] |
