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`].
@@ -170,6 +170,12 @@ impl<'a> TransmitBuf<'a> {
170170 self . buf_capacity
171171 }
172172
173+ /// Whether the buffer has capacity for another datagram after the current one
174+ pub ( super ) fn has_datagram_capacity ( & self ) -> bool {
175+ let max_buffer_size = self . segment_size * self . max_datagrams ;
176+ self . buf_capacity < max_buffer_size
177+ }
178+
173179 /// Returns `true` if the buffer did not have anything written into it
174180 pub ( super ) fn is_empty ( & self ) -> bool {
175181 self . len ( ) == 0
You can’t perform that action at this time.
0 commit comments