mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 16:21:39 +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 {
|
loop {
|
||||||
match this.write_state {
|
match this.write_state {
|
||||||
WriteState::Init => return Poll::Ready(Ok(())),
|
WriteState::Init => return Pin::new(&mut this.io).poll_flush(cx),
|
||||||
WriteState::BufferData { off } => {
|
WriteState::BufferData { off } => {
|
||||||
trace!("flush: encrypting {} bytes", off);
|
trace!("flush: encrypting {} bytes", off);
|
||||||
match this.session.write_message(&buffer.write[.. off], buffer.write_crypto) {
|
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 {
|
if len == *off {
|
||||||
trace!("flush: finished writing {} bytes", len);
|
trace!("flush: finished writing {} bytes", len);
|
||||||
this.write_state = WriteState::Init;
|
this.write_state = WriteState::Init;
|
||||||
return Poll::Ready(Ok(()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteState::Eof => {
|
WriteState::Eof => {
|
||||||
@ -425,6 +424,7 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
|||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Poll<Result<(), std::io::Error>>{
|
) -> Poll<Result<(), std::io::Error>>{
|
||||||
|
ready!(Pin::new(&mut *self).poll_flush(cx))?;
|
||||||
Pin::new(&mut self.io).poll_close(cx)
|
Pin::new(&mut self.io).poll_close(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user