Skip to content

Commit

Permalink
io: fix formatting in CopyBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Armillus committed May 5, 2024
1 parent 676fa45 commit c43ed10
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions tokio/src/io/util/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,28 @@ impl CopyBuffer {
}
// Ignore pending reads when our buffer is not empty, because
// we can try to write data immediately.
Poll::Pending => if self.pos == self.cap {
// Try flushing when the reader has no progress to avoid deadlock
// when the reader depends on buffered writer.
if self.need_flush {
ready!(writer.as_mut().poll_flush(cx))?;
#[cfg(any(
feature = "fs",
feature = "io-std",
feature = "net",
feature = "process",
feature = "rt",
feature = "signal",
feature = "sync",
feature = "time",
))]
coop.made_progress();
self.need_flush = false;
}
Poll::Pending => {
if self.pos == self.cap {
// Try flushing when the reader has no progress to avoid deadlock
// when the reader depends on buffered writer.
if self.need_flush {
ready!(writer.as_mut().poll_flush(cx))?;
#[cfg(any(
feature = "fs",
feature = "io-std",
feature = "net",
feature = "process",
feature = "rt",
feature = "signal",
feature = "sync",
feature = "time",
))]
coop.made_progress();
self.need_flush = false;
}

return Poll::Pending;
return Poll::Pending;
}
}
}
}
Expand Down

0 comments on commit c43ed10

Please sign in to comment.