Skip to content

Commit

Permalink
warnings fix + more fiving timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Lee committed Nov 26, 2024
1 parent 99a930f commit c866288
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
14 changes: 8 additions & 6 deletions src/net/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
};

use rand::Rng;
use sysctl::Sysctl;
use tokio::{net::UdpSocket, sync::RwLock};

use crate::{
Expand Down Expand Up @@ -60,12 +59,15 @@ impl BluefinServer {
self.socket = Some(Arc::new(socket));

#[cfg(target_os = "macos")]
if let Ok(ctl) = sysctl::Ctl::new("net.inet.udp.maxdgram") {
match ctl.set_value_string("16000") {
Ok(s) => {
println!("Successfully set net.inet.udp.maxdgram to {}", s)
{
use sysctl::Sysctl;
if let Ok(ctl) = sysctl::Ctl::new("net.inet.udp.maxdgram") {
match ctl.set_value_string("16000") {
Ok(s) => {
println!("Successfully set net.inet.udp.maxdgram to {}", s)
}
Err(e) => eprintln!("Failed to set net.inet.udp.maxdgram due to err: {:?}", e),
}
Err(e) => eprintln!("Failed to set net.inet.udp.maxdgram due to err: {:?}", e),
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/worker/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,7 @@ impl WriterRxChannel {

#[cfg(kani)]
mod verification_tests {
use crate::{
core::packet::BluefinPacket,
net::{MAX_BLUEFIN_BYTES_IN_UDP_DATAGRAM, MAX_BLUEFIN_PAYLOAD_SIZE_BYTES},
worker::writer::{WriterQueue, WriterQueueData},
};
use crate::worker::writer::WriterQueue;

#[kani::proof]
fn kani_writer_queue_consume_empty_data_behaves_as_expected() {
Expand Down
19 changes: 9 additions & 10 deletions tests/basic/basic_handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn loopback_ip_addr() -> Ipv4Addr {
}

#[rstest]
#[timeout(Duration::from_secs(5))]
#[timeout(Duration::from_secs(15))]
#[case(1318, 1319, 10)]
#[case(1320, 1321, 100)]
#[case(1322, 1323, 222)]
Expand All @@ -67,6 +67,7 @@ async fn basic_server_client_connection_send_recv(
.bind()
.await
.expect("Encountered error while binding server");
let _ = server.set_num_reader_workers(20);

let mut client = BluefinClient::new(std::net::SocketAddr::V4(SocketAddrV4::new(
*loopback_ip_addr,
Expand All @@ -78,7 +79,7 @@ async fn basic_server_client_connection_send_recv(
let mut join_set = JoinSet::new();

join_set.spawn(async move {
let mut conn = timeout(Duration::from_secs(3), server.accept())
let mut conn = timeout(Duration::from_secs(10), server.accept())
.await
.expect("Server timed out waiting to accept connection from client")
.expect("Failed to create bluefin connection");
Expand Down Expand Up @@ -162,8 +163,8 @@ async fn basic_server_client_connection_send_recv(
.await
.expect("Client timed out waiting to connect to server");

// Wait for 250ms for the server to be ready
sleep(Duration::from_millis(250)).await;
// Wait for 100ms for the server to be ready
sleep(Duration::from_millis(100)).await;

// Send TOTAL_NUM_BYTES_SENT across the wire
let mut total_num_bytes_sent = 0;
Expand Down Expand Up @@ -264,13 +265,11 @@ async fn basic_server_client_connection_send_recv(
}

#[rstest]
#[timeout(Duration::from_secs(10))]
#[timeout(Duration::from_secs(15))]
#[tokio::test]
async fn basic_server_client_multiple_connections_send_recv(loopback_ip_addr: &Ipv4Addr) {
use std::sync::Arc;

use rand::Rng;

let mut server = BluefinServer::new(std::net::SocketAddr::V4(SocketAddrV4::new(
*loopback_ip_addr,
1419,
Expand All @@ -281,17 +280,17 @@ async fn basic_server_client_multiple_connections_send_recv(loopback_ip_addr: &I
.expect("Encountered error while binding server");

let mut join_set = JoinSet::new();
const NUM_CONNECTIONS: usize = 5;
const NUM_CONNECTIONS: usize = 3;
const MAX_BYTES_SENT_PER_CONNECTION: usize = 3200;
let client_ports: [u16; NUM_CONNECTIONS] = [1420, 1421, 1422, 1423, 1424];
let client_ports: [u16; NUM_CONNECTIONS] = [1420, 1421, 1422];
let loopback_cloned = loopback_ip_addr.clone();
let data = Arc::new(generate_connection_date(NUM_CONNECTIONS));

for conn_num in 0..NUM_CONNECTIONS {
let mut s = server.clone();
let data_cloned = Arc::clone(&data);
join_set.spawn(async move {
let mut conn = timeout(Duration::from_secs(5), s.accept())
let mut conn = timeout(Duration::from_secs(10), s.accept())
.await
.expect(&format!(
"Server #{} timed out waiting to accept connection from client",
Expand Down

0 comments on commit c866288

Please sign in to comment.