File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
quinn-proto/src/connection Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -562,7 +562,7 @@ impl Connection {
562562 // We need to send 1 more datagram and extend the buffer for that.
563563
564564 // Is 1 more datagram allowed?
565- if buf. datagram_max_offset ( ) >= buf . segment_size ( ) * buf . max_datagrams {
565+ if ! buf. has_datagram_capacity ( ) {
566566 // No more datagrams allowed
567567 break ;
568568 }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ pub(super) struct TransmitBuf<'a> {
3535 /// size. All datagrams in between need to be exactly this size.
3636 buf_capacity : usize ,
3737 /// The maximum number of datagrams allowed to write into [`TransmitBuf::buf`]
38- pub ( super ) max_datagrams : usize ,
38+ max_datagrams : usize ,
3939 /// The number of datagrams already (partially) written into the buffer
4040 ///
4141 /// Incremented by a call to [`TransmitBuf::start_next_datagram`].
@@ -104,6 +104,12 @@ impl<'a> TransmitBuf<'a> {
104104 self . buf_capacity
105105 }
106106
107+ /// Whether the buffer has capacity for another datagram after the current one
108+ pub ( super ) fn has_datagram_capacity ( & self ) -> bool {
109+ let max_buffer_size = self . segment_size * self . max_datagrams ;
110+ self . buf_capacity < max_buffer_size
111+ }
112+
107113 /// Clips the datagram size to the current size
108114 ///
109115 /// Only valid for the first datagram, when the datagram might be smaller than the
You can’t perform that action at this time.
0 commit comments