Skip to content

Commit 0b636f0

Browse files
committed
Introduce helper for the capacity of the entire transmit
1 parent 8d60a9b commit 0b636f0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,10 @@ impl Connection {
576576
// for starting another datagram. If there is any anti-amplification
577577
// budget left, we always allow a full MTU to be sent
578578
// (see https://github.com/quinn-rs/quinn/issues/1082)
579-
if self.path.anti_amplification_blocked(
580-
(transmit.segment_size() * transmit.num_datagrams()) as u64 + 1,
581-
) {
579+
if self
580+
.path
581+
.anti_amplification_blocked(transmit.capacity() as u64 + 1)
582+
{
582583
trace!("blocked by anti-amplification");
583584
break;
584585
}

quinn-proto/src/connection/transmit_builder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ impl<'a> TransmitBuilder<'a> {
165165
self.num_datagrams >= self.max_datagrams
166166
}
167167

168+
/// The sum of the capacity of all started datagrams in the transmit
169+
///
170+
/// This might be more than [`len`] when the current datagram is not yet fully
171+
/// written. In other words: this is the length of the transmit when the current
172+
/// datagram would fill the entire segment size.
173+
///
174+
/// [`len`]: TransmitBuf::len
175+
pub(super) fn capacity(&self) -> usize {
176+
self.segment_size * self.num_datagrams
177+
}
178+
168179
/// Returns the GSO segment size
169180
///
170181
/// This is also the maximum size datagrams are allowed to be. The first and last

0 commit comments

Comments
 (0)