Skip to content

Commit 3496fe3

Browse files
committed
---
yaml --- r: 94781 b: refs/heads/try c: 743d392 h: refs/heads/master i: 94779: 90ee894 v: v3
1 parent 75b5b0c commit 3496fe3

File tree

16 files changed

+371
-1138
lines changed

16 files changed

+371
-1138
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 200c52a34e7673ab4186f86394c52874c98b4ffa
5+
refs/heads/try: 743d39293f8f480cd4104a4de1ec659bc0e3a955
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,7 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
30713071
30723072
# #[crate_type = "lib"];
30733073
// Package ID
3074-
#[pkgid = "farm#2.5"];
3074+
#[crate_id = "farm#2.5"];
30753075
30763076
// ...
30773077
# fn farm() {}
@@ -3095,7 +3095,7 @@ or setting the crate type (library or executable) explicitly:
30953095
// ...
30963096
30973097
// This crate is a library ("bin" is the default)
3098-
#[pkgid = "farm#2.5"];
3098+
#[crate_id = "farm#2.5"];
30993099
#[crate_type = "lib"];
31003100
31013101
// Turn on a warning
@@ -3116,7 +3116,7 @@ We define two crates, and use one of them as a library in the other.
31163116

31173117
~~~~
31183118
// world.rs
3119-
#[pkgid = "world#0.42"];
3119+
#[crate_id = "world#0.42"];
31203120
# extern mod extra;
31213121
pub fn explore() -> &'static str { "world" }
31223122
# fn main() {}

branches/try/src/libnative/io/file.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::IoResult;
2626
#[cfg(windows)] use std::ptr;
2727
#[cfg(windows)] use std::str;
2828

29-
pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
29+
fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
3030
#[cfg(windows)] static eintr: int = 0; // doesn't matter
3131
#[cfg(not(windows))] static eintr: int = libc::EINTR as int;
3232

@@ -37,7 +37,7 @@ pub fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
3737
let mut ret;
3838
loop {
3939
ret = f(data, amt);
40-
if cfg!(windows) { break } // windows has no eintr
40+
if cfg!(not(windows)) { break } // windows has no eintr
4141
// if we get an eintr, then try again
4242
if ret != -1 || os::errno() as int != eintr { break }
4343
}
@@ -73,10 +73,7 @@ impl FileDesc {
7373
FileDesc { fd: fd, close_on_drop: close_on_drop }
7474
}
7575

76-
// FIXME(#10465) these functions should not be public, but anything in
77-
// native::io wanting to use them is forced to have all the
78-
// rtio traits in scope
79-
pub fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
76+
fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
8077
#[cfg(windows)] type rlen = libc::c_uint;
8178
#[cfg(not(windows))] type rlen = libc::size_t;
8279
let ret = keep_going(buf, |buf, len| {
@@ -92,7 +89,7 @@ impl FileDesc {
9289
Ok(ret as uint)
9390
}
9491
}
95-
pub fn inner_write(&mut self, buf: &[u8]) -> Result<(), IoError> {
92+
fn inner_write(&mut self, buf: &[u8]) -> Result<(), IoError> {
9693
#[cfg(windows)] type wlen = libc::c_uint;
9794
#[cfg(not(windows))] type wlen = libc::size_t;
9895
let ret = keep_going(buf, |buf, len| {
@@ -106,8 +103,6 @@ impl FileDesc {
106103
Ok(())
107104
}
108105
}
109-
110-
pub fn fd(&self) -> fd_t { self.fd }
111106
}
112107

113108
impl io::Reader for FileDesc {

branches/try/src/libnative/io/mod.rs

Lines changed: 13 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub use self::process::Process;
4444
// Native I/O implementations
4545
pub mod file;
4646
pub mod process;
47-
pub mod net;
4847

4948
type IoResult<T> = Result<T, IoError>;
5049

@@ -56,25 +55,12 @@ fn unimpl() -> IoError {
5655
}
5756
}
5857

59-
fn translate_error(errno: i32, detail: bool) -> IoError {
58+
fn last_error() -> IoError {
6059
#[cfg(windows)]
6160
fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
6261
match errno {
6362
libc::EOF => (io::EndOfFile, "end of file"),
64-
libc::WSAECONNREFUSED => (io::ConnectionRefused, "connection refused"),
65-
libc::WSAECONNRESET => (io::ConnectionReset, "connection reset"),
66-
libc::WSAEACCES => (io::PermissionDenied, "permission denied"),
67-
libc::WSAEWOULDBLOCK =>
68-
(io::ResourceUnavailable, "resource temporarily unavailable"),
69-
libc::WSAENOTCONN => (io::NotConnected, "not connected"),
70-
libc::WSAECONNABORTED => (io::ConnectionAborted, "connection aborted"),
71-
libc::WSAEADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
72-
libc::WSAEADDRINUSE => (io::ConnectionRefused, "address in use"),
73-
74-
x => {
75-
debug!("ignoring {}: {}", x, os::last_os_error());
76-
(io::OtherIoError, "unknown error")
77-
}
63+
_ => (io::OtherIoError, "unknown error"),
7864
}
7965
}
8066

@@ -83,38 +69,24 @@ fn translate_error(errno: i32, detail: bool) -> IoError {
8369
// XXX: this should probably be a bit more descriptive...
8470
match errno {
8571
libc::EOF => (io::EndOfFile, "end of file"),
86-
libc::ECONNREFUSED => (io::ConnectionRefused, "connection refused"),
87-
libc::ECONNRESET => (io::ConnectionReset, "connection reset"),
88-
libc::EPERM | libc::EACCES =>
89-
(io::PermissionDenied, "permission denied"),
90-
libc::EPIPE => (io::BrokenPipe, "broken pipe"),
91-
libc::ENOTCONN => (io::NotConnected, "not connected"),
92-
libc::ECONNABORTED => (io::ConnectionAborted, "connection aborted"),
93-
libc::EADDRNOTAVAIL => (io::ConnectionRefused, "address not available"),
94-
libc::EADDRINUSE => (io::ConnectionRefused, "address in use"),
9572

9673
// These two constants can have the same value on some systems, but
9774
// different values on others, so we can't use a match clause
9875
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK =>
9976
(io::ResourceUnavailable, "resource temporarily unavailable"),
10077

101-
x => {
102-
debug!("ignoring {}: {}", x, os::last_os_error());
103-
(io::OtherIoError, "unknown error")
104-
}
78+
_ => (io::OtherIoError, "unknown error"),
10579
}
10680
}
10781

108-
let (kind, desc) = get_err(errno);
82+
let (kind, desc) = get_err(os::errno() as i32);
10983
IoError {
11084
kind: kind,
11185
desc: desc,
112-
detail: if detail {Some(os::last_os_error())} else {None},
86+
detail: Some(os::last_os_error())
11387
}
11488
}
11589

116-
fn last_error() -> IoError { translate_error(os::errno() as i32, true) }
117-
11890
// unix has nonzero values as errors
11991
fn mkerr_libc(ret: libc::c_int) -> IoResult<()> {
12092
if ret != 0 {
@@ -134,37 +106,17 @@ fn mkerr_winbool(ret: libc::c_int) -> IoResult<()> {
134106
}
135107
}
136108

137-
#[cfg(unix)]
138-
fn retry(f: || -> libc::c_int) -> IoResult<libc::c_int> {
139-
loop {
140-
match f() {
141-
-1 if os::errno() as int == libc::EINTR as int => {}
142-
-1 => return Err(last_error()),
143-
n => return Ok(n),
144-
}
145-
}
146-
}
147-
148109
/// Implementation of rt::rtio's IoFactory trait to generate handles to the
149110
/// native I/O functionality.
150-
pub struct IoFactory {
151-
priv cannot_construct_outside_of_this_module: ()
152-
}
153-
154-
impl IoFactory {
155-
pub fn new() -> IoFactory {
156-
net::init();
157-
IoFactory { cannot_construct_outside_of_this_module: () }
158-
}
159-
}
111+
pub struct IoFactory;
160112

161113
impl rtio::IoFactory for IoFactory {
162114
// networking
163-
fn tcp_connect(&mut self, addr: SocketAddr) -> IoResult<~RtioTcpStream> {
164-
net::TcpStream::connect(addr).map(|s| ~s as ~RtioTcpStream)
115+
fn tcp_connect(&mut self, _addr: SocketAddr) -> IoResult<~RtioTcpStream> {
116+
Err(unimpl())
165117
}
166-
fn tcp_bind(&mut self, addr: SocketAddr) -> IoResult<~RtioTcpListener> {
167-
net::TcpListener::bind(addr).map(|s| ~s as ~RtioTcpListener)
118+
fn tcp_bind(&mut self, _addr: SocketAddr) -> IoResult<~RtioTcpListener> {
119+
Err(unimpl())
168120
}
169121
fn udp_bind(&mut self, _addr: SocketAddr) -> IoResult<~RtioUdpSocket> {
170122
Err(unimpl())
@@ -252,7 +204,9 @@ impl rtio::IoFactory for IoFactory {
252204
}
253205
fn tty_open(&mut self, fd: c_int, _readable: bool) -> IoResult<~RtioTTY> {
254206
if unsafe { libc::isatty(fd) } != 0 {
255-
Ok(~file::FileDesc::new(fd, true) as ~RtioTTY)
207+
// Don't ever close the stdio file descriptors, nothing good really
208+
// comes of that.
209+
Ok(~file::FileDesc::new(fd, fd > libc::STDERR_FILENO) as ~RtioTTY)
256210
} else {
257211
Err(IoError {
258212
kind: io::MismatchedFileTypeForOperation,

0 commit comments

Comments
 (0)