Skip to content

Commit

Permalink
Fix poll_flush after poll_shutdown (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbai authored Feb 3, 2025
1 parent 02eb53b commit 07e528f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/codec/framed_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ macro_rules! limited_write_buf {
pub struct FramedWrite<T, B> {
/// Upstream `AsyncWrite`
inner: T,
final_flush_done: bool,

encoder: Encoder<B>,
}
Expand Down Expand Up @@ -89,6 +90,7 @@ where
};
FramedWrite {
inner,
final_flush_done: false,
encoder: Encoder {
hpack: hpack::Encoder::default(),
buf: Cursor::new(BytesMut::with_capacity(DEFAULT_BUFFER_CAPACITY)),
Expand Down Expand Up @@ -165,7 +167,10 @@ where

/// Close the codec
pub fn shutdown(&mut self, cx: &mut Context) -> Poll<io::Result<()>> {
ready!(self.flush(cx))?;
if !self.final_flush_done {
ready!(self.flush(cx))?;
self.final_flush_done = true;
}
Pin::new(&mut self.inner).poll_shutdown(cx)
}
}
Expand Down

0 comments on commit 07e528f

Please sign in to comment.