Skip to content

Commit

Permalink
share the stream counter for unstaked connections as well (anza-xyz#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs authored Apr 22, 2024
1 parent d4b8692 commit 0e96ea6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,16 +1194,10 @@ impl ConnectionTable {
if has_connection_capacity {
let exit = Arc::new(AtomicBool::new(false));
let last_update = Arc::new(AtomicU64::new(last_update));
let stream_counter = if peer_type.is_staked() {
connection_entry
.first()
.map(|entry| entry.stream_counter.clone())
.unwrap_or(Arc::new(ConnectionStreamCounter::new()))
} else {
// Unstaked connections are tracked using peer IP address. It's possible that different clients
// use the same IP due to NAT. So counting all the streams from a given IP could be too restrictive.
Arc::new(ConnectionStreamCounter::new())
};
let stream_counter = connection_entry
.first()
.map(|entry| entry.stream_counter.clone())
.unwrap_or(Arc::new(ConnectionStreamCounter::new()));
connection_entry.push(ConnectionEntry::new(
exit.clone(),
peer_type,
Expand Down

0 comments on commit 0e96ea6

Please sign in to comment.