From ebc1b9d684c500b6bc02142a23ee534fce96db4a Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Mon, 22 Jan 2024 18:45:05 -0800 Subject: [PATCH] Reduce coercion --- quinn-proto/src/connection/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 6b87f5082..124b977d7 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -617,9 +617,10 @@ impl Connection { // for starting another datagram. If there is any anti-amplification // budget left, we always allow a full MTU to be sent // (see https://github.com/quinn-rs/quinn/issues/1082) - if self.path.anti_amplification_blocked( - self.path.current_mtu() as u64 * num_datagrams as u64 + 1, - ) { + if self + .path + .anti_amplification_blocked(self.path.current_mtu() as u64 * num_datagrams + 1) + { trace!("blocked by anti-amplification"); break; } @@ -728,7 +729,7 @@ impl Connection { space_id, buf, buf_capacity, - (num_datagrams - 1) * (self.path.current_mtu() as usize), + (num_datagrams as usize - 1) * (self.path.current_mtu() as usize), ack_eliciting, self, self.version, @@ -898,7 +899,7 @@ impl Connection { trace!("sending {} bytes in {} datagrams", buf.len(), num_datagrams); self.path.total_sent = self.path.total_sent.saturating_add(buf.len() as u64); - self.stats.udp_tx.on_sent(num_datagrams as u64, buf.len()); + self.stats.udp_tx.on_sent(num_datagrams, buf.len()); Some(Transmit { destination: self.path.remote,