Browse Source

Remove TCP no-delay (#7484)

pull/7491/head
Dave Bakker 1 year ago
committed by GitHub
parent
commit
fa8933c6e3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      crates/test-programs/src/bin/preview2_tcp_sockopts.rs
  2. 8
      crates/test-programs/src/bin/preview2_tcp_states.rs
  3. 7
      crates/wasi-http/wit/deps/sockets/tcp.wit
  4. 12
      crates/wasi/src/preview2/host/tcp.rs
  5. 7
      crates/wasi/wit/deps/sockets/tcp.wit

15
crates/test-programs/src/bin/preview2_tcp_sockopts.rs

@ -13,7 +13,6 @@ fn test_tcp_sockopt_defaults(family: IpAddressFamily) {
}
sock.keep_alive().unwrap(); // Only verify that it has a default value at all, but either value is valid.
assert_eq!(sock.no_delay().unwrap(), false);
assert!(sock.unicast_hop_limit().unwrap() > 0);
assert!(sock.receive_buffer_size().unwrap() > 0);
assert!(sock.send_buffer_size().unwrap() > 0);
@ -33,9 +32,6 @@ fn test_tcp_sockopt_input_ranges(family: IpAddressFamily) {
assert!(matches!(sock.set_keep_alive(true), Ok(_)));
assert!(matches!(sock.set_keep_alive(false), Ok(_)));
assert!(matches!(sock.set_no_delay(true), Ok(_)));
assert!(matches!(sock.set_no_delay(false), Ok(_)));
assert!(matches!(
sock.set_unicast_hop_limit(0),
Err(ErrorCode::InvalidArgument)
@ -64,11 +60,6 @@ fn test_tcp_sockopt_readback(family: IpAddressFamily) {
sock.set_keep_alive(false).unwrap();
assert_eq!(sock.keep_alive().unwrap(), false);
sock.set_no_delay(true).unwrap();
assert_eq!(sock.no_delay().unwrap(), true);
sock.set_no_delay(false).unwrap();
assert_eq!(sock.no_delay().unwrap(), false);
sock.set_unicast_hop_limit(42).unwrap();
assert_eq!(sock.unicast_hop_limit().unwrap(), 42);
@ -93,7 +84,6 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {
}
listener.set_keep_alive(!default_keep_alive).unwrap();
listener.set_no_delay(true).unwrap();
listener.set_unicast_hop_limit(42).unwrap();
listener.set_receive_buffer_size(0x10000).unwrap();
listener.set_send_buffer_size(0x10000).unwrap();
@ -113,7 +103,6 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {
}
assert_eq!(accepted_client.keep_alive().unwrap(), !default_keep_alive);
assert_eq!(accepted_client.no_delay().unwrap(), true);
assert_eq!(accepted_client.unicast_hop_limit().unwrap(), 42);
assert_eq!(accepted_client.receive_buffer_size().unwrap(), 0x10000);
assert_eq!(accepted_client.send_buffer_size().unwrap(), 0x10000);
@ -122,7 +111,6 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {
// Update options on listener to something else:
{
listener.set_keep_alive(default_keep_alive).unwrap();
listener.set_no_delay(false).unwrap();
listener.set_unicast_hop_limit(43).unwrap();
listener.set_receive_buffer_size(0x20000).unwrap();
listener.set_send_buffer_size(0x20000).unwrap();
@ -131,7 +119,6 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {
// Verify that the already accepted socket was not affected:
{
assert_eq!(accepted_client.keep_alive().unwrap(), !default_keep_alive);
assert_eq!(accepted_client.no_delay().unwrap(), true);
assert_eq!(accepted_client.unicast_hop_limit().unwrap(), 42);
assert_eq!(accepted_client.receive_buffer_size().unwrap(), 0x10000);
assert_eq!(accepted_client.send_buffer_size().unwrap(), 0x10000);
@ -150,7 +137,6 @@ fn test_tcp_sockopt_after_listen(net: &Network, family: IpAddressFamily) {
// Update options while the socket is already listening:
{
listener.set_keep_alive(!default_keep_alive).unwrap();
listener.set_no_delay(true).unwrap();
listener.set_unicast_hop_limit(42).unwrap();
listener.set_receive_buffer_size(0x10000).unwrap();
listener.set_send_buffer_size(0x10000).unwrap();
@ -163,7 +149,6 @@ fn test_tcp_sockopt_after_listen(net: &Network, family: IpAddressFamily) {
// Verify options on accepted socket:
{
assert_eq!(accepted_client.keep_alive().unwrap(), !default_keep_alive);
assert_eq!(accepted_client.no_delay().unwrap(), true);
assert_eq!(accepted_client.unicast_hop_limit().unwrap(), 42);
assert_eq!(accepted_client.receive_buffer_size().unwrap(), 0x10000);
assert_eq!(accepted_client.send_buffer_size().unwrap(), 0x10000);

8
crates/test-programs/src/bin/preview2_tcp_states.rs

@ -51,8 +51,6 @@ fn test_tcp_unbound_state_invariants(family: IpAddressFamily) {
assert!(matches!(sock.set_listen_backlog_size(32), Ok(_)));
assert!(matches!(sock.keep_alive(), Ok(_)));
assert!(matches!(sock.set_keep_alive(false), Ok(_)));
assert!(matches!(sock.no_delay(), Ok(_)));
assert!(matches!(sock.set_no_delay(false), Ok(_)));
assert!(matches!(sock.unicast_hop_limit(), Ok(_)));
assert!(matches!(sock.set_unicast_hop_limit(255), Ok(_)));
assert!(matches!(sock.receive_buffer_size(), Ok(_)));
@ -111,8 +109,6 @@ fn test_tcp_bound_state_invariants(net: &Network, family: IpAddressFamily) {
assert!(matches!(sock.set_listen_backlog_size(32), Ok(_)));
assert!(matches!(sock.keep_alive(), Ok(_)));
assert!(matches!(sock.set_keep_alive(false), Ok(_)));
assert!(matches!(sock.no_delay(), Ok(_)));
assert!(matches!(sock.set_no_delay(false), Ok(_)));
assert!(matches!(sock.unicast_hop_limit(), Ok(_)));
assert!(matches!(sock.set_unicast_hop_limit(255), Ok(_)));
assert!(matches!(sock.receive_buffer_size(), Ok(_)));
@ -178,8 +174,6 @@ fn test_tcp_listening_state_invariants(net: &Network, family: IpAddressFamily) {
));
assert!(matches!(sock.keep_alive(), Ok(_)));
assert!(matches!(sock.set_keep_alive(false), Ok(_)));
assert!(matches!(sock.no_delay(), Ok(_)));
assert!(matches!(sock.set_no_delay(false), Ok(_)));
assert!(matches!(sock.unicast_hop_limit(), Ok(_)));
assert!(matches!(sock.set_unicast_hop_limit(255), Ok(_)));
assert!(matches!(sock.receive_buffer_size(), Ok(_)));
@ -238,8 +232,6 @@ fn test_tcp_connected_state_invariants(net: &Network, family: IpAddressFamily) {
assert!(matches!(sock.keep_alive(), Ok(_)));
assert!(matches!(sock.set_keep_alive(false), Ok(_)));
assert!(matches!(sock.no_delay(), Ok(_)));
assert!(matches!(sock.set_no_delay(false), Ok(_)));
assert!(matches!(sock.unicast_hop_limit(), Ok(_)));
assert!(matches!(sock.set_unicast_hop_limit(255), Ok(_)));
assert!(matches!(sock.receive_buffer_size(), Ok(_)));

7
crates/wasi-http/wit/deps/sockets/tcp.wit

@ -126,7 +126,6 @@ interface tcp {
/// - `address-family`
/// - `ipv6-only`
/// - `keep-alive`
/// - `no-delay`
/// - `unicast-hop-limit`
/// - `receive-buffer-size`
/// - `send-buffer-size`
@ -204,12 +203,6 @@ interface tcp {
keep-alive: func() -> result<bool, error-code>;
set-keep-alive: func(value: bool) -> result<_, error-code>;
/// Equivalent to the TCP_NODELAY socket option.
///
/// The default value is `false`.
no-delay: func() -> result<bool, error-code>;
set-no-delay: func(value: bool) -> result<_, error-code>;
/// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
///
/// # Typical errors

12
crates/wasi/src/preview2/host/tcp.rs

@ -415,18 +415,6 @@ impl<T: WasiView> crate::preview2::host::tcp::tcp::HostTcpSocket for T {
Ok(sockopt::set_socket_keepalive(socket.tcp_socket(), value)?)
}
fn no_delay(&mut self, this: Resource<tcp::TcpSocket>) -> SocketResult<bool> {
let table = self.table();
let socket = table.get(&this)?;
Ok(sockopt::get_tcp_nodelay(socket.tcp_socket())?)
}
fn set_no_delay(&mut self, this: Resource<tcp::TcpSocket>, value: bool) -> SocketResult<()> {
let table = self.table();
let socket = table.get(&this)?;
Ok(sockopt::set_tcp_nodelay(socket.tcp_socket(), value)?)
}
fn unicast_hop_limit(&mut self, this: Resource<tcp::TcpSocket>) -> SocketResult<u8> {
let table = self.table();
let socket = table.get(&this)?;

7
crates/wasi/wit/deps/sockets/tcp.wit

@ -126,7 +126,6 @@ interface tcp {
/// - `address-family`
/// - `ipv6-only`
/// - `keep-alive`
/// - `no-delay`
/// - `unicast-hop-limit`
/// - `receive-buffer-size`
/// - `send-buffer-size`
@ -204,12 +203,6 @@ interface tcp {
keep-alive: func() -> result<bool, error-code>;
set-keep-alive: func(value: bool) -> result<_, error-code>;
/// Equivalent to the TCP_NODELAY socket option.
///
/// The default value is `false`.
no-delay: func() -> result<bool, error-code>;
set-no-delay: func(value: bool) -> result<_, error-code>;
/// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
///
/// # Typical errors

Loading…
Cancel
Save