@@ -152,64 +152,60 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
152
152
match uv:: ll:: tcp_init ( loop_ptr, stream_handle_ptr) {
153
153
0i32 => {
154
154
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);
213
209
}
214
210
}
215
211
}
0 commit comments