From c8b19b3d573b616b6c346e7068ee3796e55c2a2b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:49:42 -0700 Subject: [PATCH] v1.18: quic: delay calling set_max_concurrent_uni_streams/set_receive_window (backport of #904) (#968) 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) Co-authored-by: Alessandro Decina --- 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,