Skip to content

Commit 9007ebc

Browse files
committed
---
yaml --- r: 30130 b: refs/heads/incoming c: 8453097 h: refs/heads/master v: v3
1 parent 1cc7a97 commit 9007ebc

File tree

2 files changed

+55
-59
lines changed

2 files changed

+55
-59
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 6d788198d784c126ca75475f5a0178722db82d56
9+
refs/heads/incoming: 8453097dd52f6fdd6a710c382978af02d7f55844
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libstd/net_tcp.rs

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -152,64 +152,60 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
152152
match uv::ll::tcp_init( loop_ptr, stream_handle_ptr) {
153153
0i32 => {
154154
log(debug, ~"tcp_init successful");
155-
match input_ip {
156-
_ipv4 => {
157-
log(debug, ~"dealing w/ ipv4 connection..");
158-
let connect_req_ptr =
159-
ptr::addr_of((*socket_data_ptr).connect_req);
160-
let addr_str = ip::format_addr(input_ip);
161-
let connect_result = match input_ip {
162-
ip::ipv4(addr) => {
163-
// have to "recreate" the sockaddr_in/6
164-
// since the ip_addr discards the port
165-
// info.. should probably add an additional
166-
// rust type that actually is closer to
167-
// what the libuv API expects (ip str + port num)
168-
log(debug, fmt!("addr: %?", addr));
169-
let in_addr = uv::ll::ip4_addr(addr_str, port as int);
170-
uv::ll::tcp_connect(
171-
connect_req_ptr,
172-
stream_handle_ptr,
173-
ptr::addr_of(in_addr),
174-
tcp_connect_on_connect_cb)
175-
}
176-
ip::ipv6(addr) => {
177-
log(debug, fmt!("addr: %?", addr));
178-
let in_addr = uv::ll::ip6_addr(addr_str, port as int);
179-
uv::ll::tcp_connect6(
180-
connect_req_ptr,
181-
stream_handle_ptr,
182-
ptr::addr_of(in_addr),
183-
tcp_connect_on_connect_cb)
184-
}
185-
};
186-
match connect_result {
187-
0i32 => {
188-
log(debug, ~"tcp_connect successful");
189-
// reusable data that we'll have for the
190-
// duration..
191-
uv::ll::set_data_for_uv_handle(stream_handle_ptr,
192-
socket_data_ptr as
193-
*libc::c_void);
194-
// just so the connect_cb can send the
195-
// outcome..
196-
uv::ll::set_data_for_req(connect_req_ptr,
197-
conn_data_ptr);
198-
log(debug, ~"leaving tcp_connect interact cb...");
199-
// let tcp_connect_on_connect_cb send on
200-
// the result_ch, now..
201-
}
202-
_ => {
203-
// immediate connect failure.. probably a garbage
204-
// ip or somesuch
205-
let err_data = uv::ll::get_last_err_data(loop_ptr);
206-
core::comm::send((*conn_data_ptr).result_ch,
207-
conn_failure(err_data.to_tcp_err()));
208-
uv::ll::set_data_for_uv_handle(stream_handle_ptr,
209-
conn_data_ptr);
210-
uv::ll::close(stream_handle_ptr, stream_error_close_cb);
211-
}
212-
}
155+
log(debug, ~"dealing w/ ipv4 connection..");
156+
let connect_req_ptr =
157+
ptr::addr_of((*socket_data_ptr).connect_req);
158+
let addr_str = ip::format_addr(input_ip);
159+
let connect_result = match input_ip {
160+
ip::ipv4(addr) => {
161+
// have to "recreate" the sockaddr_in/6
162+
// since the ip_addr discards the port
163+
// info.. should probably add an additional
164+
// rust type that actually is closer to
165+
// what the libuv API expects (ip str + port num)
166+
log(debug, fmt!("addr: %?", addr));
167+
let in_addr = uv::ll::ip4_addr(addr_str, port as int);
168+
uv::ll::tcp_connect(
169+
connect_req_ptr,
170+
stream_handle_ptr,
171+
ptr::addr_of(in_addr),
172+
tcp_connect_on_connect_cb)
173+
}
174+
ip::ipv6(addr) => {
175+
log(debug, fmt!("addr: %?", addr));
176+
let in_addr = uv::ll::ip6_addr(addr_str, port as int);
177+
uv::ll::tcp_connect6(
178+
connect_req_ptr,
179+
stream_handle_ptr,
180+
ptr::addr_of(in_addr),
181+
tcp_connect_on_connect_cb)
182+
}
183+
};
184+
match connect_result {
185+
0i32 => {
186+
log(debug, ~"tcp_connect successful");
187+
// reusable data that we'll have for the
188+
// duration..
189+
uv::ll::set_data_for_uv_handle(stream_handle_ptr,
190+
socket_data_ptr as
191+
*libc::c_void);
192+
// just so the connect_cb can send the
193+
// outcome..
194+
uv::ll::set_data_for_req(connect_req_ptr,
195+
conn_data_ptr);
196+
log(debug, ~"leaving tcp_connect interact cb...");
197+
// let tcp_connect_on_connect_cb send on
198+
// the result_ch, now..
199+
}
200+
_ => {
201+
// immediate connect failure.. probably a garbage
202+
// ip or somesuch
203+
let err_data = uv::ll::get_last_err_data(loop_ptr);
204+
core::comm::send((*conn_data_ptr).result_ch,
205+
conn_failure(err_data.to_tcp_err()));
206+
uv::ll::set_data_for_uv_handle(stream_handle_ptr,
207+
conn_data_ptr);
208+
uv::ll::close(stream_handle_ptr, stream_error_close_cb);
213209
}
214210
}
215211
}

0 commit comments

Comments
 (0)