Skip to content

Commit 96b7285

Browse files
committed
---
yaml --- r: 151588 b: refs/heads/try2 c: 611c2ae h: refs/heads/master v: v3
1 parent 5be83d7 commit 96b7285

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
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: a57889a58012a53146de7ba54e234a025a9b30c4
8+
refs/heads/try2: 611c2ae4f1411a36e3010a3a4f9145115a3a0e88
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/io/net/tcp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ impl TcpStream {
6363
/// `host` can be a hostname or IP address string. If no error is
6464
/// encountered, then `Ok(stream)` is returned.
6565
pub fn connect(host: &str, port: u16) -> IoResult<TcpStream> {
66-
let addresses = try!(get_host_addresses(host));
66+
let addresses = match FromStr::from_str(host) {
67+
Some(addr) => vec!(addr),
68+
None => try!(get_host_addresses(host))
69+
};
6770
let mut err = IoError{
6871
kind: ConnectionFailed,
6972
desc: "no addresses found for hostname",

branches/try2/src/test/run-pass/tcp-stress.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ fn main() {
3737
unsafe { libc::exit(1) }
3838
});
3939

40-
let host = "127.0.0.1";
41-
let port = 0;
4240
let (tx, rx) = channel();
4341
spawn(proc() {
44-
let mut listener = TcpListener::bind(host, port).unwrap();
42+
let mut listener = TcpListener::bind("127.0.0.1", 0).unwrap();
4543
tx.send(listener.socket_name().unwrap());
4644
let mut acceptor = listener.listen();
4745
loop {
@@ -57,15 +55,15 @@ fn main() {
5755
}
5856
});
5957
let addr = rx.recv();
60-
let host = addr.ip.to_str();
61-
let port = addr.port;
6258

6359
let (tx, rx) = channel();
6460
for _ in range(0, 1000) {
6561
let tx = tx.clone();
6662
let mut builder = TaskBuilder::new();
6763
builder.opts.stack_size = Some(32 * 1024);
6864
builder.spawn(proc() {
65+
let host = addr.ip.to_str();
66+
let port = addr.port;
6967
match TcpStream::connect(host, port) {
7068
Ok(stream) => {
7169
let mut stream = stream;

0 commit comments

Comments
 (0)