diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-11-09 11:02:16 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-11-10 12:23:57 -0800 |
| commit | e38a89d0b0fcc3b2f5cad600d7b3a16faeb94248 (patch) | |
| tree | 68f474d86ebf9a96a47259aaf2f3626a02d70eb5 /src/libstd/rt | |
| parent | c5fdd69d3e197cef64a4f29faff5d42a95010647 (diff) | |
| download | rust-e38a89d0b0fcc3b2f5cad600d7b3a16faeb94248.tar.gz rust-e38a89d0b0fcc3b2f5cad600d7b3a16faeb94248.zip | |
Fix usage of libuv for windows
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/io/stdio.rs | 12 | ||||
| -rw-r--r-- | src/libstd/rt/io/timer.rs | 8 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/libstd/rt/io/stdio.rs b/src/libstd/rt/io/stdio.rs index 674b34639bc..acc2e11f067 100644 --- a/src/libstd/rt/io/stdio.rs +++ b/src/libstd/rt/io/stdio.rs @@ -33,7 +33,8 @@ use result::{Ok, Err}; use rt::io::buffered::LineBufferedWriter; use rt::rtio::{IoFactory, RtioTTY, RtioFileStream, with_local_io, CloseAsynchronously}; -use super::{Reader, Writer, io_error, IoError, OtherIoError}; +use super::{Reader, Writer, io_error, IoError, OtherIoError, + standard_error, EndOfFile}; // And so begins the tale of acquiring a uv handle to a stdio stream on all // platforms in all situations. Our story begins by splitting the world into two @@ -203,6 +204,15 @@ impl Reader for StdReader { File(ref mut file) => file.read(buf).map(|i| i as uint), }; match ret { + // When reading a piped stdin, libuv will return 0-length reads when + // stdin reaches EOF. For pretty much all other streams it will + // return an actual EOF error, but apparently for stdin it's a + // little different. Hence, here we convert a 0 length read to an + // end-of-file indicator so the caller knows to stop reading. + Ok(0) => { + io_error::cond.raise(standard_error(EndOfFile)); + None + } Ok(amt) => Some(amt as uint), Err(e) => { io_error::cond.raise(e); diff --git a/src/libstd/rt/io/timer.rs b/src/libstd/rt/io/timer.rs index fed6b9daa64..b0cf7dee10a 100644 --- a/src/libstd/rt/io/timer.rs +++ b/src/libstd/rt/io/timer.rs @@ -142,14 +142,10 @@ mod test { fn oneshot_twice() { do run_in_mt_newsched_task { let mut timer = Timer::new().unwrap(); - let port1 = timer.oneshot(100000000000); + let port1 = timer.oneshot(10000); let port = timer.oneshot(1); port.recv(); - let port1 = Cell::new(port1); - let ret = do task::try { - port1.take().recv(); - }; - assert!(ret.is_err()); + assert_eq!(port1.try_recv(), None); } } |
