From 763e6f46e06d05bc23148d1c05b9516a6f02b1ba Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:54:38 +0000 Subject: [PATCH] Early return in `do_poll_read` instead of keep polling if there're some data already written to `output`, so that the next component in pipeline can process it instead of being blocked. --- crates/async-compression/src/generic/bufread/encoder.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/async-compression/src/generic/bufread/encoder.rs b/crates/async-compression/src/generic/bufread/encoder.rs index 4187c9b7..e6fe4b07 100644 --- a/crates/async-compression/src/generic/bufread/encoder.rs +++ b/crates/async-compression/src/generic/bufread/encoder.rs @@ -35,9 +35,12 @@ impl Encoder { State::Encoding(mut read) => match input.as_mut() { None => { if read == 0 { - // Poll for more data - // TODO (nobodyxu): Return Ok if `!output.written().is_empty()` - break; + if output.written().is_empty() { + // Poll for more data + break; + } else { + return ControlFlow::Break(Ok(())); + } } else { State::Flushing }