Skip to content

Commit

Permalink
quic: delay calling set_max_concurrent_uni_streams/set_receive_window (
Browse files Browse the repository at this point in the history
…anza-xyz#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
  • Loading branch information
alessandrod authored Apr 22, 2024
1 parent 0e96ea6 commit 2770424
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,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,
Expand All @@ -392,6 +386,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,
Expand Down

0 comments on commit 2770424

Please sign in to comment.