about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeremy Soller <jackpot51@gmail.com>2016-11-14 20:56:06 -0700
committerJeremy Soller <jackpot51@gmail.com>2016-11-14 20:56:06 -0700
commit73f24d47dee367563019b18ac5089b91eded2753 (patch)
treede10f1f250b5e9348d929f6f7c08fab41c6fa555
parentde68aced95ab53bc0f69ff4d6867a03d2dd0f8d7 (diff)
downloadrust-73f24d47dee367563019b18ac5089b91eded2753.tar.gz
rust-73f24d47dee367563019b18ac5089b91eded2753.zip
Simple implementation of read2
-rw-r--r--src/libstd/sys/redox/pipe.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libstd/sys/redox/pipe.rs b/src/libstd/sys/redox/pipe.rs
index a25ca048942..fff4a10f913 100644
--- a/src/libstd/sys/redox/pipe.rs
+++ b/src/libstd/sys/redox/pipe.rs
@@ -23,9 +23,7 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
 
     libc::pipe2(&mut fds, libc::O_CLOEXEC).map_err(|err| io::Error::from_raw_os_error(err.errno))?;
 
-    let fd0 = FileDesc::new(fds[0]);
-    let fd1 = FileDesc::new(fds[1]);
-    Ok((AnonPipe::from_fd(fd0)?, AnonPipe::from_fd(fd1)?))
+    Ok((AnonPipe(FileDesc::new(fds[0])), AnonPipe(FileDesc::new(fds[1]))))
 }
 
 impl AnonPipe {
@@ -50,12 +48,18 @@ impl AnonPipe {
     pub fn into_fd(self) -> FileDesc { self.0 }
 }
 
-pub fn read2(_p1: AnonPipe,
-             _v1: &mut Vec<u8>,
-             _p2: AnonPipe,
-             _v2: &mut Vec<u8>) -> io::Result<()> {
-    ::sys_common::util::dumb_print(format_args!("read2\n"));
-    unimplemented!();
+pub fn read2(p1: AnonPipe,
+             v1: &mut Vec<u8>,
+             p2: AnonPipe,
+             v2: &mut Vec<u8>) -> io::Result<()> {
+    //TODO: Use event based I/O multiplexing
+    //unimplemented!()
+
+    p1.read_to_end(v1)?;
+    p2.read_to_end(v2)?;
+
+    Ok(())
+
     /*
     // Set both pipes into nonblocking mode as we're gonna be reading from both
     // in the `select` loop below, and we wouldn't want one to block the other!
@@ -64,7 +68,6 @@ pub fn read2(_p1: AnonPipe,
     p1.set_nonblocking(true)?;
     p2.set_nonblocking(true)?;
 
-    let max = cmp::max(p1.raw(), p2.raw());
     loop {
         // wait for either pipe to become readable using `select`
         cvt_r(|| unsafe {