From 4e8a09e5ada6772cdbcc018e11c9ac923ea34eeb Mon Sep 17 00:00:00 2001 From: Lijun Wang <83639177+lijunwangs@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:46:04 -0700 Subject: [PATCH] style fixes --- streamer/src/nonblocking/quic.rs | 71 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index 5cf259271b50b2..4b41f89240168b 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -406,39 +406,41 @@ async fn run_server( let client_connection_tracker = ClientConnectionTracker::new(stats.clone(), max_concurrent_connections); - if client_connection_tracker.is_err() { - stats - .refused_connections_too_many_open_connections - .fetch_add(1, Ordering::Relaxed); - incoming.refuse(); - continue; - } - let client_connection_tracker = client_connection_tracker.unwrap(); - - stats - .outstanding_incoming_connection_attempts - .fetch_add(1, Ordering::Relaxed); - let connecting = incoming.accept(); - match connecting { - Ok(connecting) => { - tokio::spawn(setup_connection( - connecting, - client_connection_tracker, - unstaked_connection_table.clone(), - staked_connection_table.clone(), - sender.clone(), - max_connections_per_peer, - staked_nodes.clone(), - max_staked_connections, - max_unstaked_connections, - max_streams_per_ms, - stats.clone(), - wait_for_chunk_timeout, - stream_load_ema.clone(), - )); + match client_connection_tracker { + Err(_) => { + stats + .refused_connections_too_many_open_connections + .fetch_add(1, Ordering::Relaxed); + incoming.refuse(); + continue; } - Err(err) => { - debug!("Incoming::accept(): error {:?}", err); + Ok(client_connection_tracker) => { + stats + .outstanding_incoming_connection_attempts + .fetch_add(1, Ordering::Relaxed); + let connecting = incoming.accept(); + match connecting { + Ok(connecting) => { + tokio::spawn(setup_connection( + connecting, + client_connection_tracker, + unstaked_connection_table.clone(), + staked_connection_table.clone(), + sender.clone(), + max_connections_per_peer, + staked_nodes.clone(), + max_staked_connections, + max_unstaked_connections, + max_streams_per_ms, + stats.clone(), + wait_for_chunk_timeout, + stream_load_ema.clone(), + )); + } + Err(err) => { + debug!("Incoming::accept(): error {:?}", err); + } + } } } } else { @@ -1296,9 +1298,8 @@ struct ConnectionEntry { peer_type: ConnectionPeerType, last_update: Arc, port: u16, - #[allow(dead_code)] // We do not explicitly use it, but its drop is triggered when ConnectionEntry is dropped. - client_connection_tracker: ClientConnectionTracker, + _client_connection_tracker: ClientConnectionTracker, connection: Option, stream_counter: Arc, } @@ -1318,7 +1319,7 @@ impl ConnectionEntry { peer_type, last_update, port, - client_connection_tracker, + _client_connection_tracker: client_connection_tracker, connection, stream_counter, }