mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-30 00:00:16 +02:00
io: add assert in copy_bidirectional that poll_write is sensible (#4125)
This commit is contained in:
@@ -84,6 +84,14 @@ impl CopyBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If pos larger than cap, this loop will never stop.
|
||||||
|
// In particular, user's wrong poll_write implementation returning
|
||||||
|
// incorrect written length may lead to thread blocking.
|
||||||
|
debug_assert!(
|
||||||
|
self.pos <= self.cap,
|
||||||
|
"writer returned length larger than input slice"
|
||||||
|
);
|
||||||
|
|
||||||
// If we've written all the data and we've seen EOF, flush out the
|
// If we've written all the data and we've seen EOF, flush out the
|
||||||
// data and finish the transfer.
|
// data and finish the transfer.
|
||||||
if self.pos == self.cap && self.read_done {
|
if self.pos == self.cap && self.read_done {
|
||||||
|
|||||||
Reference in New Issue
Block a user