mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-25 15:51:34 +00:00
Fix noise/io.rs not flushing the underlying stream
This commit is contained in:
@ -353,7 +353,7 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
|
||||
loop {
|
||||
match this.write_state {
|
||||
WriteState::Init => return Poll::Ready(Ok(())),
|
||||
WriteState::Init => return Pin::new(&mut this.io).poll_flush(cx),
|
||||
WriteState::BufferData { off } => {
|
||||
trace!("flush: encrypting {} bytes", off);
|
||||
match this.session.write_message(&buffer.write[.. off], buffer.write_crypto) {
|
||||
@ -409,7 +409,6 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
if len == *off {
|
||||
trace!("flush: finished writing {} bytes", len);
|
||||
this.write_state = WriteState::Init;
|
||||
return Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
WriteState::Eof => {
|
||||
@ -425,6 +424,7 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), std::io::Error>>{
|
||||
ready!(Pin::new(&mut *self).poll_flush(cx))?;
|
||||
Pin::new(&mut self.io).poll_close(cx)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user