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 @@ -37,7 +37,7 @@ pub(super) struct TransmitBuf<'a> {
3737 /// size. All datagrams in between need to be exactly this size.
3838 buf_capacity : usize ,
3939 /// The maximum number of datagrams allowed to write into [`TransmitBuf::buf`]
40- pub ( super ) max_datagrams : usize ,
40+ max_datagrams : usize ,
4141 /// The number of datagrams already (partially) written into the buffer
4242 ///
4343 /// Incremented by a call to [`TransmitBuf::start_new_datagram`].
@@ -106,6 +106,12 @@ impl<'a> TransmitBuf<'a> {
106106 self . buf_capacity
107107 }
108108
109+ /// Whether the buffer has capacity for another datagram after the current one
110+ pub ( super ) fn has_datagram_capacity ( & self ) -> bool {
111+ let max_buffer_size = self . segment_size * self . max_datagrams ;
112+ self . buf_capacity < max_buffer_size
113+ }
114+
109115 /// Clips the datagram size to the current size
110116 ///
111117 /// 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