Skip to content

Commit 0f261f6

Browse files
committed
Add helper for first datagram
1 parent 0b636f0 commit 0f261f6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl Connection {
629629
builder.pad_to(MIN_INITIAL_SIZE);
630630
}
631631

632-
if transmit.num_datagrams() > 1 {
632+
if !transmit.is_first_datagram() {
633633
// If too many padding bytes would be required to continue the GSO batch
634634
// after this packet, end the GSO batch here. Ensures that fixed-size frames
635635
// with heterogeneous sizes (e.g. application datagrams) won't inadvertently
@@ -670,7 +670,7 @@ impl Connection {
670670
&mut transmit.datagram_mut(),
671671
);
672672

673-
if transmit.num_datagrams() == 1 {
673+
if transmit.is_first_datagram() {
674674
transmit.clip_datagram_size();
675675
if space_id == SpaceId::Data {
676676
// Now that we know the size of the first datagram, check
@@ -827,7 +827,7 @@ impl Connection {
827827

828828
// Send an off-path PATH_RESPONSE. Prioritized over on-path data to ensure that path
829829
// validation can occur while the link is saturated.
830-
if space_id == SpaceId::Data && transmit.num_datagrams() == 1 {
830+
if space_id == SpaceId::Data && transmit.is_first_datagram() {
831831
let mut datagram = transmit.datagram_mut();
832832
if let Some((token, remote)) = self.path_responses.pop_off_path(self.path.remote) {
833833
// `unwrap` guaranteed to succeed because `builder_storage` was populated just

quinn-proto/src/connection/transmit_builder.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ impl<'a> TransmitBuilder<'a> {
176176
self.segment_size * self.num_datagrams
177177
}
178178

179+
/// Whether the current datagram is the first in the transmit buffer
180+
pub(super) fn is_first_datagram(&self) -> bool {
181+
self.num_datagrams == 1
182+
}
183+
179184
/// Returns the GSO segment size
180185
///
181186
/// This is also the maximum size datagrams are allowed to be. The first and last

0 commit comments

Comments
 (0)