Skip to content

Commit 302f328

Browse files
committed
Address datagram review nits
1 parent 7960a26 commit 302f328

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

quinn-proto/src/connection/datagrams.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ impl Datagrams<'_> {
3232
let max = self
3333
.max_size()
3434
.ok_or(SendDatagramError::UnsupportedByPeer)?;
35-
if data.len() > max {
36-
return Err(SendDatagramError::TooLarge);
37-
}
38-
if data.len() > self.conn.config.datagram_send_buffer_size {
35+
if data.len() > Ord::min(max, self.conn.config.datagram_send_buffer_size) {
3936
return Err(SendDatagramError::TooLarge);
4037
}
4138
if drop {
@@ -149,9 +146,11 @@ impl DatagramState {
149146
}
150147

151148
fn has_send_buffer_space(&self, datagram_len: usize, send_buffer_size: usize) -> bool {
152-
self.outgoing_total
153-
.checked_add(datagram_len)
154-
.is_some_and(|total| total <= send_buffer_size)
149+
let Some(total) = self.outgoing_total.checked_add(datagram_len) else {
150+
return false;
151+
};
152+
153+
total <= send_buffer_size
155154
}
156155

157156
/// Discard outgoing datagrams with a payload larger than `max_payload` bytes

0 commit comments

Comments
 (0)