Skip to content

Commit

Permalink
Only wake up the connection driver if necessary
Browse files Browse the repository at this point in the history
Add a has_pending_retransmits method to
quinn_proto::connection::Connection and use it inside of
quinn::RecvStream::poll_read_generic to decide if we should wake up the
connection driver.
  • Loading branch information
geieredgar authored and djc committed Jan 29, 2021
1 parent f1977f5 commit 4985f3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ where
self.zero_rtt_enabled
}

/// Whether there are any pending retransmits
pub fn has_pending_retransmits(&self) -> bool {
!self.spaces[SpaceId::Data].pending.is_empty()
}

/// Look up whether we're the client or server of this Connection
pub fn side(&self) -> Side {
self.side
Expand Down
5 changes: 3 additions & 2 deletions quinn/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ where
}
match read_fn(&mut conn, self.stream) {
Ok(Some(u)) => {
// Flow control credit may have been issued
conn.wake();
if conn.inner.has_pending_retransmits() {
conn.wake()
}
Poll::Ready(Ok(Some(u)))
}
Ok(None) => {
Expand Down

0 comments on commit 4985f3a

Please sign in to comment.