Skip to content

Commit

Permalink
proposal to expand (a subset of) linux specific socket capabilities.
Browse files Browse the repository at this point in the history
to stabilise the quickack part for now, tcp_deferaccept had been added at a
later stage.
  • Loading branch information
devnexen committed Aug 15, 2024
1 parent 026e9ed commit 1666f86
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion library/std/src/os/android/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub use crate::os::net::linux_ext::socket::UnixSocketExt;
#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
2 changes: 1 addition & 1 deletion library/std/src/os/linux/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub use crate::os::net::linux_ext::socket::UnixSocketExt;
#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
2 changes: 1 addition & 1 deletion library/std/src/os/net/linux_ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) mod addr;
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub(crate) mod socket;

#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub(crate) mod tcp;

#[cfg(test)]
Expand Down
12 changes: 5 additions & 7 deletions library/std/src/os/net/linux_ext/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{io, net};
/// Os-specific extensions for [`TcpStream`]
///
/// [`TcpStream`]: net::TcpStream
#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub trait TcpStreamExt: Sealed {
/// Enable or disable `TCP_QUICKACK`.
///
Expand All @@ -23,15 +23,14 @@ pub trait TcpStreamExt: Sealed {
/// # Examples
///
/// ```no_run
/// #![feature(tcp_quickack)]
/// use std::net::TcpStream;
/// use std::os::linux::net::TcpStreamExt;
///
/// let stream = TcpStream::connect("127.0.0.1:8080")
/// .expect("Couldn't connect to the server...");
/// stream.set_quickack(true).expect("set_quickack call failed");
/// ```
#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
fn set_quickack(&self, quickack: bool) -> io::Result<()>;

/// Gets the value of the `TCP_QUICKACK` option on this socket.
Expand All @@ -41,7 +40,6 @@ pub trait TcpStreamExt: Sealed {
/// # Examples
///
/// ```no_run
/// #![feature(tcp_quickack)]
/// use std::net::TcpStream;
/// use std::os::linux::net::TcpStreamExt;
///
Expand All @@ -50,7 +48,7 @@ pub trait TcpStreamExt: Sealed {
/// stream.set_quickack(true).expect("set_quickack call failed");
/// assert_eq!(stream.quickack().unwrap_or(false), true);
/// ```
#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
fn quickack(&self) -> io::Result<bool>;

/// A socket listener will be awakened solely when data arrives.
Expand Down Expand Up @@ -99,10 +97,10 @@ pub trait TcpStreamExt: Sealed {
fn deferaccept(&self) -> io::Result<u32>;
}

#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
impl Sealed for net::TcpStream {}

#[unstable(feature = "tcp_quickack", issue = "96256")]
#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
impl TcpStreamExt for net::TcpStream {
fn set_quickack(&self, quickack: bool) -> io::Result<()> {
self.as_inner().as_inner().set_quickack(quickack)
Expand Down

0 comments on commit 1666f86

Please sign in to comment.