From e4905c31006eb6aa36e7586cc57c9104d2f9973e Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Thu, 16 Jan 2020 19:50:16 +0100 Subject: [PATCH] Extra comments --- crates/wasi-common/src/sys/windows/hostcalls_impl/misc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/wasi-common/src/sys/windows/hostcalls_impl/misc.rs b/crates/wasi-common/src/sys/windows/hostcalls_impl/misc.rs index 1403e2f4d5..40e6d694e2 100644 --- a/crates/wasi-common/src/sys/windows/hostcalls_impl/misc.rs +++ b/crates/wasi-common/src/sys/windows/hostcalls_impl/misc.rs @@ -72,7 +72,10 @@ impl StdinPoll { fn event_loop(request_rx: Receiver<()>, notify_tx: Sender) -> ! { use std::io::BufRead; loop { + // Wait for the request to poll stdin request_rx.recv().expect("request_rx channel closed"); + + // Wait for data to appear in stdin. // If `fill_buf` returns any slice, then it means that either // (a) there some data in stdout, if it's non-empty // (b) EOF was received, if it's empty @@ -81,6 +84,9 @@ impl StdinPoll { Ok(_) => PollState::Ready, Err(e) => PollState::Error(e.into()), }; + + // Notify the requestor about data in stdin. They may have already timed out, + // then the next requestor will have to clean the channel. notify_tx.send(resp).expect("notify_tx channel closed"); } }