From 4131c9bd2a776b367b119cc4deddaebf7d24b3e9 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 23 Apr 2024 03:56:20 +1000 Subject: [PATCH] quic: delay calling set_max_concurrent_uni_streams/set_receive_window (#904) * quic: don't call connection.set_max_concurrent_uni_streams if we're going to drop a connection Avoids taking a mutex and waking a task. * quic: don't increase the receive window before we've actually accepted a connection (cherry picked from commit 2770424782bcb07561e101b2f5cb83d1fad9a7b2) --- streamer/src/nonblocking/quic.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index 5d297013fb3039..1a9ba7433b4021 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -345,16 +345,10 @@ fn handle_and_cache_new_connection( params.total_stake, ) as u64) { - connection.set_max_concurrent_uni_streams(max_uni_streams); + let remote_addr = connection.remote_address(); let receive_window = compute_recieve_window(params.max_stake, params.min_stake, params.peer_type); - if let Ok(receive_window) = receive_window { - connection.set_receive_window(receive_window); - } - - let remote_addr = connection.remote_address(); - debug!( "Peer type {:?}, total stake {}, max streams {} receive_window {:?} from peer {}", params.peer_type, @@ -375,6 +369,12 @@ fn handle_and_cache_new_connection( ) { drop(connection_table_l); + + if let Ok(receive_window) = receive_window { + connection.set_receive_window(receive_window); + } + connection.set_max_concurrent_uni_streams(max_uni_streams); + tokio::spawn(handle_connection( connection, remote_addr,