Skip to content

Commit

Permalink
feat: allow maximum buffer size for backpressure (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac authored Oct 4, 2023
1 parent 73a1b26 commit 55b721c
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 92 deletions.
7 changes: 7 additions & 0 deletions src/connection_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl ConnectionStream {
StreamProgress::NoInterest => {
// Write it
let n = self.tls.writer().write(buf).expect("Write will never fail");
trace!("w={n}");
assert!(n > 0);
// Drain what we can
while self.poll_write_only(cx) == StreamProgress::MadeProgress {}
Expand All @@ -303,6 +304,12 @@ impl ConnectionStream {
res
}

/// Fully write a buffer to the TLS stream, expecting it to write fully and not fail.
pub(crate) fn write_buf_fully(&mut self, buf: &[u8]) {
let n = self.tls.writer().write(buf).expect("Write will never fail");
assert_eq!(n, buf.len())
}

/// Polls for completion of all the writes in the rustls [`Connection`]. Does not progress on
/// reads at all.
pub fn poll_flush(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Expand Down
Loading

0 comments on commit 55b721c

Please sign in to comment.