Open
Description
Using a tokio_test::io::Mock
to read and write simultaneously via tokio::io::split
causes lockup if the Mock
is waiting, and there's no data to read.
This is a simple test, enough to trigger it for me:
#[tokio::test]
async fn check_io() {
let socket = tokio_test::io::Builder::new()
.wait(Duration::from_millis(10))
.write([0].as_slice())
.build();
let (mut recv, mut send) = tokio::io::split(socket);
tokio::spawn(async move { recv.read_u8().await.unwrap() });
send.write_u8(0).await.unwrap();
}
I'm not super familiar with the Mock API, but I'd expect this to finish after 10ms, possibly with an error due to the extra read. Instead, it hangs forever.
As far as I'm aware, this should not be a problem unless the Mock is blocking in a poll call of some sort, which may be a deeper issue?
Version
├── tokio v1.45.0
│ └── tokio-macros v2.5.0 (proc-macro)
└── tokio-openssl v0.6.5
└── tokio v1.45.0 (*)
└── tokio v1.45.0 (*)
├── tokio v1.45.0 (*)
└── tokio-util v0.7.15
└── tokio v1.45.0 (*)
├── tokio v1.45.0 (*)
└── tokio-test v0.4.4
├── tokio v1.45.0 (*)
└── tokio-stream v0.1.17
└── tokio v1.45.0 (*)
Platform
Linux [...] 5.15.0-139-generic #149~20.04.1-Ubuntu SMP [...] x86_64 x86_64 x86_64 GNU/Linux