Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions glommio/src/io/buffered_file_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,12 @@ impl AsyncBufRead for Stdin {
) -> Poll<io::Result<&'a [u8]>> {
match self.source.take() {
Some(source) => {
let res = source.result().unwrap();
let res = match source.result() {
Some(res) => res,
None => {
return Poll::Pending;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is the correct fix, but it does fix both the test case and when using stdin in my program to read from it

}
};
match res {
Err(x) => Poll::Ready(Err(x)),
Ok(sz) => {
Expand Down Expand Up @@ -691,9 +696,9 @@ impl AsyncBufRead for Stdin {
#[cfg(test)]
mod test {
use super::*;
use crate::test_utils::make_test_directories;
use crate::{test_utils::make_test_directories, GlommioError};
use futures_lite::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt, AsyncWriteExt, StreamExt};
use std::io::ErrorKind;
use std::{io::ErrorKind, time::Duration};

macro_rules! read_test {
( $name:ident, $dir:ident, $kind:ident, $file:ident, $file_size:ident: $size:tt, $code:block) => {
Expand Down Expand Up @@ -982,4 +987,20 @@ mod test {
reader.close().await.unwrap();
writer.close().await.unwrap();
});

#[test]
fn test_stdin_fuse() {
use futures::StreamExt;

test_executor!(async move {
let mut si = StreamExt::fuse(stdin().lines());
let fut =
crate::timer::timeout(Duration::from_millis(1), async move {
StreamExt::next(&mut si).await.ok_or(GlommioError::IoError(
std::io::Error::new(std::io::ErrorKind::BrokenPipe, "stdin closed"),
))
});
assert!(matches!(fut.await, Err(GlommioError::TimedOut(_))));
});
}
}