From bd7e31225478a5a7eb6d7b151b9ade71ac0a30f6 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) # Conflicts: # streamer/src/nonblocking/quic.rs --- streamer/src/nonblocking/quic.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index 38200ea15fe71a..f430fee6eadf55 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -333,6 +333,7 @@ fn handle_and_cache_new_connection( params.total_stake, ) as u64) { +<<<<<<< HEAD connection.set_max_concurrent_uni_streams(max_uni_streams); let receive_window = compute_recieve_window( params.max_stake, @@ -340,12 +341,11 @@ fn handle_and_cache_new_connection( connection_table_l.peer_type, params.stake, ); - - if let Ok(receive_window) = receive_window { - connection.set_receive_window(receive_window); - } - +======= let remote_addr = connection.remote_address(); + let receive_window = + compute_recieve_window(params.max_stake, params.min_stake, params.peer_type); +>>>>>>> 2770424782 (quic: delay calling set_max_concurrent_uni_streams/set_receive_window (#904)) debug!( "Peer type: {:?}, stake {}, total stake {}, max streams {} receive_window {:?} from peer {}", @@ -367,6 +367,12 @@ fn handle_and_cache_new_connection( ) { let peer_type = connection_table_l.peer_type; 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,