Skip to content

Commit 0215081

Browse files
committed
---
yaml --- r: 146157 b: refs/heads/try2 c: 32b07c6 h: refs/heads/master i: 146155: 06f4f45 v: v3
1 parent 1124cb0 commit 0215081

File tree

8 files changed

+27
-51
lines changed

8 files changed

+27
-51
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c6fa4e277f5eb873e979d8ac1ae7a4c3ccb1e9cc
8+
refs/heads/try2: 32b07c6a40bd7e1874244096f413096a6e059a29
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/rt/io/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ pub use self::net::tcp::TcpListener;
261261
pub use self::net::tcp::TcpStream;
262262
pub use self::net::udp::UdpStream;
263263
pub use self::pipe::PipeStream;
264-
pub use self::pipe::UnboundPipeStream;
265264
pub use self::process::Process;
266265

267266
// Some extension traits that all Readers and Writers get.

branches/try2/src/libstd/rt/io/pipe.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,13 @@
1616
use prelude::*;
1717
use super::{Reader, Writer};
1818
use rt::io::{io_error, read_error, EndOfFile};
19-
use rt::local::Local;
20-
use rt::rtio::{RtioPipe, RtioPipeObject, IoFactoryObject, IoFactory};
21-
use rt::rtio::RtioUnboundPipeObject;
19+
use rt::rtio::{RtioPipe, RtioPipeObject};
2220

2321
pub struct PipeStream {
2422
priv obj: ~RtioPipeObject
2523
}
2624

27-
// This should not be a newtype, but rt::uv::process::set_stdio needs to reach
28-
// into the internals of this :(
29-
pub struct UnboundPipeStream(~RtioUnboundPipeObject);
30-
3125
impl PipeStream {
32-
/// Creates a new pipe initialized, but not bound to any particular
33-
/// source/destination
34-
pub fn new() -> Option<UnboundPipeStream> {
35-
let pipe = unsafe {
36-
let io: *mut IoFactoryObject = Local::unsafe_borrow();
37-
(*io).pipe_init(false)
38-
};
39-
match pipe {
40-
Ok(p) => Some(UnboundPipeStream(p)),
41-
Err(ioerr) => {
42-
io_error::cond.raise(ioerr);
43-
None
44-
}
45-
}
46-
}
47-
4826
pub fn new_bound(inner: ~RtioPipeObject) -> PipeStream {
4927
PipeStream { obj: inner }
5028
}

branches/try2/src/libstd/rt/io/process.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ pub enum StdioContainer {
7070
/// specified for.
7171
InheritFd(libc::c_int),
7272

73-
/// Creates a pipe for the specified file descriptor which will be directed
74-
/// into the previously-initialized pipe passed in.
73+
/// Creates a pipe for the specified file descriptor which will be created
74+
/// when the process is spawned.
7575
///
7676
/// The first boolean argument is whether the pipe is readable, and the
7777
/// second is whether it is writable. These properties are from the view of
7878
/// the *child* process, not the parent process.
79-
CreatePipe(io::UnboundPipeStream,
80-
bool /* readable */,
81-
bool /* writable */),
79+
CreatePipe(bool /* readable */, bool /* writable */),
8280
}
8381

8482
impl Process {

branches/try2/src/libstd/rt/rtio.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub type RtioUdpSocketObject = uvio::UvUdpSocket;
3535
pub type RtioTimerObject = uvio::UvTimer;
3636
pub type PausibleIdleCallback = uvio::UvPausibleIdleCallback;
3737
pub type RtioPipeObject = uvio::UvPipeStream;
38-
pub type RtioUnboundPipeObject = uvio::UvUnboundPipe;
3938
pub type RtioProcessObject = uvio::UvProcess;
4039
pub type RtioUnixListenerObject = uvio::UvUnixListener;
4140
pub type RtioUnixAcceptorObject = uvio::UvUnixAcceptor;
@@ -88,7 +87,6 @@ pub trait IoFactory {
8887
fn fs_rmdir<P: PathLike>(&mut self, path: &P) -> Result<(), IoError>;
8988
fn fs_readdir<P: PathLike>(&mut self, path: &P, flags: c_int) ->
9089
Result<~[Path], IoError>;
91-
fn pipe_init(&mut self, ipc: bool) -> Result<~RtioUnboundPipeObject, IoError>;
9290
fn spawn(&mut self, config: ProcessConfig)
9391
-> Result<(~RtioProcessObject, ~[Option<~RtioPipeObject>]), IoError>;
9492

branches/try2/src/libstd/rt/uv/process.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use vec;
1717

1818
use rt::io::process::*;
1919
use rt::uv;
20-
use rt::uv::uvio::UvPipeStream;
20+
use rt::uv::uvio::{UvPipeStream, UvUnboundPipe};
2121
use rt::uv::uvll;
2222

2323
/// A process wraps the handle of the underlying uv_process_t.
@@ -68,7 +68,8 @@ impl Process {
6868
unsafe {
6969
vec::raw::set_len(&mut stdio, io.len());
7070
for (slot, other) in stdio.iter().zip(io.move_iter()) {
71-
let io = set_stdio(slot as *uvll::uv_stdio_container_t, other);
71+
let io = set_stdio(slot as *uvll::uv_stdio_container_t, other,
72+
loop_);
7273
ret_io.push(io);
7374
}
7475
}
@@ -144,7 +145,8 @@ impl Process {
144145
}
145146

146147
unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
147-
io: StdioContainer) -> Option<~UvPipeStream> {
148+
io: StdioContainer,
149+
loop_: &uv::Loop) -> Option<~UvPipeStream> {
148150
match io {
149151
Ignored => {
150152
uvll::set_stdio_container_flags(dst, uvll::STDIO_IGNORE);
@@ -155,18 +157,19 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
155157
uvll::set_stdio_container_fd(dst, fd);
156158
None
157159
}
158-
CreatePipe(pipe, readable, writable) => {
160+
CreatePipe(readable, writable) => {
159161
let mut flags = uvll::STDIO_CREATE_PIPE as libc::c_int;
160162
if readable {
161163
flags |= uvll::STDIO_READABLE_PIPE as libc::c_int;
162164
}
163165
if writable {
164166
flags |= uvll::STDIO_WRITABLE_PIPE as libc::c_int;
165167
}
168+
let pipe = UvUnboundPipe::new_fresh(loop_);
166169
let handle = pipe.pipe.as_stream().native_handle();
167170
uvll::set_stdio_container_flags(dst, flags);
168171
uvll::set_stdio_container_stream(dst, handle);
169-
Some(~UvPipeStream::new(**pipe))
172+
Some(~UvPipeStream::new(pipe))
170173
}
171174
}
172175
}

branches/try2/src/libstd/rt/uv/uvio.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,6 @@ impl IoFactory for UvIoFactory {
749749
return result_cell.take();
750750
}
751751

752-
fn pipe_init(&mut self, ipc: bool) -> Result<~RtioUnboundPipeObject, IoError> {
753-
let home = get_handle_to_current_scheduler!();
754-
Ok(~UvUnboundPipe::new(Pipe::new(self.uv_loop(), ipc), home))
755-
}
756-
757752
fn spawn(&mut self, config: ProcessConfig)
758753
-> Result<(~RtioProcessObject, ~[Option<~RtioPipeObject>]), IoError>
759754
{
@@ -1069,9 +1064,19 @@ pub struct UvUnboundPipe {
10691064
}
10701065

10711066
impl UvUnboundPipe {
1067+
/// Takes ownership of an unbound pipe along with the scheduler that it is
1068+
/// homed on.
10721069
fn new(pipe: Pipe, home: SchedHandle) -> UvUnboundPipe {
10731070
UvUnboundPipe { pipe: pipe, home: home }
10741071
}
1072+
1073+
/// Creates a fresh new unbound pipe on the specified I/O loop
1074+
pub fn new_fresh(loop_: &Loop) -> UvUnboundPipe {
1075+
UvUnboundPipe {
1076+
pipe: Pipe::new(loop_, false),
1077+
home: get_handle_to_current_scheduler!(),
1078+
}
1079+
}
10751080
}
10761081

10771082
impl HomingIO for UvUnboundPipe {

branches/try2/src/test/run-pass/rtio-processes.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
use std::rt::io::process::{Process, ProcessConfig, CreatePipe, Ignored};
2727
use std::rt::io::{Reader, Writer};
28-
use std::rt::io::pipe::PipeStream;
2928
use std::str;
3029

3130
#[test]
@@ -105,8 +104,7 @@ fn run_output(args: ProcessConfig) -> ~str {
105104
#[test]
106105
#[cfg(unix, not(target_os="android"))]
107106
fn stdout_works() {
108-
let pipe = PipeStream::new().unwrap();
109-
let io = ~[Ignored, CreatePipe(pipe, false, true)];
107+
let io = ~[Ignored, CreatePipe(false, true)];
110108
let args = ProcessConfig {
111109
program: "/bin/sh",
112110
args: [~"-c", ~"echo foobar"],
@@ -120,8 +118,7 @@ fn stdout_works() {
120118
#[test]
121119
#[cfg(unix, not(target_os="android"))]
122120
fn set_cwd_works() {
123-
let pipe = PipeStream::new().unwrap();
124-
let io = ~[Ignored, CreatePipe(pipe, false, true)];
121+
let io = ~[Ignored, CreatePipe(false, true)];
125122
let cwd = Some("/");
126123
let args = ProcessConfig {
127124
program: "/bin/sh",
@@ -136,10 +133,8 @@ fn set_cwd_works() {
136133
#[test]
137134
#[cfg(unix, not(target_os="android"))]
138135
fn stdin_works() {
139-
let input = PipeStream::new().unwrap();
140-
let output = PipeStream::new().unwrap();
141-
let io = ~[CreatePipe(input, true, false),
142-
CreatePipe(output, false, true)];
136+
let io = ~[CreatePipe(true, false),
137+
CreatePipe(false, true)];
143138
let args = ProcessConfig {
144139
program: "/bin/sh",
145140
args: [~"-c", ~"read line; echo $line"],

0 commit comments

Comments
 (0)