Skip to content

Commit 05fecb3

Browse files
committed
changes from feedback
1 parent a1096c6 commit 05fecb3

File tree

2 files changed

+3
-5
lines changed
  • library/std/src

2 files changed

+3
-5
lines changed

library/std/src/os/net/linux_ext/tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub trait TcpStreamExt: Sealed {
6060

6161
/// A socket listener will be awakened solely when data arrives.
6262
///
63-
/// The `accept` argument set the delay in seconds until the
63+
/// The `accept` argument set the maximum delay until the
6464
/// data is available to read, reducing the number of short lived
6565
/// connections without data to process.
6666
/// Contrary to other platforms `SO_ACCEPTFILTER` feature equivalent, there is
@@ -86,7 +86,7 @@ pub trait TcpStreamExt: Sealed {
8686
#[cfg(target_os = "linux")]
8787
fn set_deferaccept(&self, accept: Duration) -> io::Result<()>;
8888

89-
/// Gets the accept delay value (in seconds) of the `TCP_DEFER_ACCEPT` option.
89+
/// Gets the accept delay value of the `TCP_DEFER_ACCEPT` option.
9090
///
9191
/// For more information about this option, see [`TcpStreamExt::set_deferaccept`].
9292
///

library/std/src/sys/net/connection/socket/unix.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,7 @@ impl Socket {
486486
// bionic libc makes no use of this flag
487487
#[cfg(target_os = "linux")]
488488
pub fn set_deferaccept(&self, accept: Duration) -> io::Result<()> {
489-
let Ok(val) = c_int::try_from(accept.as_secs()) else {
490-
return Err(io::const_error!(io::ErrorKind::InvalidInput, "awakening time overflow"));
491-
};
489+
let val = cmp::min(accept.as_secs(), c_int::MAX as u64) as c_int;
492490
setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, val)
493491
}
494492

0 commit comments

Comments
 (0)