Skip to content

Commit f45bab5

Browse files
luqmanabrson
authored andcommitted
---
yaml --- r: 36023 b: refs/heads/try2 c: 79e538d h: refs/heads/master i: 36021: e0f5da7 36019: 45b3976 36015: 2c609df v: v3
1 parent ca962f2 commit f45bab5

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
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: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0e2437bf5d4a1f863888d4b0b5995a695f966e73
8+
refs/heads/try2: 79e538d32ab33604a8288e7b76c875ff075743d2
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libstd/net_tcp.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
134134
stream_handle_ptr: stream_handle_ptr,
135135
connect_req: uv::ll::connect_t(),
136136
write_req: uv::ll::write_t(),
137+
ipv6: match input_ip {
138+
ip::Ipv4(_) => { false }
139+
ip::Ipv6(_) => { true }
140+
},
137141
iotask: iotask
138142
};
139143
let socket_data_ptr = ptr::addr_of(&(*socket_data));
@@ -475,6 +479,7 @@ pub fn accept(new_conn: TcpNewConnection)
475479
stream_handle_ptr : stream_handle_ptr,
476480
connect_req : uv::ll::connect_t(),
477481
write_req : uv::ll::write_t(),
482+
ipv6: (*server_data_ptr).ipv6,
478483
iotask : iotask
479484
};
480485
let client_socket_data_ptr = ptr::addr_of(&(*client_socket_data));
@@ -590,6 +595,10 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
590595
kill_ch: kill_ch,
591596
on_connect_cb: move on_connect_cb,
592597
iotask: iotask,
598+
ipv6: match host_ip {
599+
ip::Ipv4(_) => { false }
600+
ip::Ipv6(_) => { true }
601+
},
593602
mut active: true
594603
};
595604
let server_data_ptr = ptr::addr_of(&server_data);
@@ -748,18 +757,17 @@ impl TcpSocket {
748757
}
749758
pub fn getpeername() -> ip::IpAddr {
750759
unsafe {
751-
let addr = uv::ll::ip4_addr("", 0);
752-
uv::ll::tcp_getpeername(self.socket_data.stream_handle_ptr,
753-
ptr::addr_of(&addr));
754-
ip::Ipv4(move addr)
755-
}
756-
}
757-
pub fn getpeername6() -> ip::IpAddr {
758-
unsafe {
759-
let addr = uv::ll::ip6_addr("", 0);
760-
uv::ll::tcp_getpeername6(self.socket_data.stream_handle_ptr,
761-
ptr::addr_of(&addr));
762-
ip::Ipv6(move addr)
760+
if self.socket_data.ipv6 {
761+
let addr = uv::ll::ip6_addr("", 0);
762+
uv::ll::tcp_getpeername6(self.socket_data.stream_handle_ptr,
763+
ptr::addr_of(&addr));
764+
ip::Ipv6(move addr)
765+
} else {
766+
let addr = uv::ll::ip4_addr("", 0);
767+
uv::ll::tcp_getpeername(self.socket_data.stream_handle_ptr,
768+
ptr::addr_of(&addr));
769+
ip::Ipv4(move addr)
770+
}
763771
}
764772
}
765773
}
@@ -1019,6 +1027,7 @@ type TcpListenFcData = {
10191027
kill_ch: comm::Chan<Option<TcpErrData>>,
10201028
on_connect_cb: fn~(*uv::ll::uv_tcp_t),
10211029
iotask: IoTask,
1030+
ipv6: bool,
10221031
mut active: bool
10231032
};
10241033

@@ -1217,6 +1226,7 @@ type TcpSocketData = {
12171226
stream_handle_ptr: *uv::ll::uv_tcp_t,
12181227
connect_req: uv::ll::uv_connect_t,
12191228
write_req: uv::ll::uv_write_t,
1229+
ipv6: bool,
12201230
iotask: IoTask
12211231
};
12221232

0 commit comments

Comments
 (0)