Skip to content

Commit d789ad1

Browse files
committed
Ignore NotConnected (ENOTCONN) in Stream::close
1 parent f006e73 commit d789ad1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/io/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tokio_util::codec::{Decoder, Encoder, Framed, FramedParts};
1717
use std::{
1818
fmt,
1919
fs::File,
20-
io::Read,
20+
io::{ErrorKind::NotConnected, Read},
2121
mem::MaybeUninit,
2222
net::ToSocketAddrs,
2323
ops::{Deref, DerefMut},
@@ -334,7 +334,13 @@ impl Stream {
334334
self.closed = true;
335335
if let Some(mut codec) = self.codec {
336336
use futures_sink::Sink;
337-
futures_util::future::poll_fn(|cx| Pin::new(&mut *codec).poll_close(cx)).await?;
337+
futures_util::future::poll_fn(|cx| match Pin::new(&mut *codec).poll_close(cx) {
338+
Poll::Ready(Err(Error::Io(err))) if err.kind() == NotConnected => {
339+
Poll::Ready(Ok(()))
340+
}
341+
x => x,
342+
})
343+
.await?;
338344
}
339345
Ok(())
340346
}

0 commit comments

Comments
 (0)