Skip to content

Commit 51348b0

Browse files
committed
native: Deal with the rtio changes
1 parent da2293c commit 51348b0

File tree

10 files changed

+313
-318
lines changed

10 files changed

+313
-318
lines changed

src/libnative/io/addrinfo.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use ai = std::io::net::addrinfo;
1211
use libc::{c_char, c_int};
1312
use libc;
1413
use std::c_str::CString;
15-
use std::io::IoError;
1614
use std::mem;
1715
use std::ptr::{null, mut_null};
16+
use std::rt::rtio;
17+
use std::rt::rtio::IoError;
1818

19-
use super::net::sockaddr_to_addr;
19+
use super::net;
2020

2121
pub struct GetAddrInfoRequest;
2222

2323
impl GetAddrInfoRequest {
2424
pub fn run(host: Option<&str>, servname: Option<&str>,
25-
hint: Option<ai::Hint>) -> Result<Vec<ai::Info>, IoError> {
25+
hint: Option<rtio::AddrinfoHint>)
26+
-> Result<Vec<rtio::AddrinfoInfo>, IoError>
27+
{
2628
assert!(host.is_some() || servname.is_some());
2729

2830
let c_host = host.map_or(unsafe { CString::new(null(), true) }, |x| x.to_c_str());
@@ -61,16 +63,16 @@ impl GetAddrInfoRequest {
6163
let mut rp = res;
6264
while rp.is_not_null() {
6365
unsafe {
64-
let addr = match sockaddr_to_addr(mem::transmute((*rp).ai_addr),
65-
(*rp).ai_addrlen as uint) {
66+
let addr = match net::sockaddr_to_addr(mem::transmute((*rp).ai_addr),
67+
(*rp).ai_addrlen as uint) {
6668
Ok(a) => a,
6769
Err(e) => return Err(e)
6870
};
69-
addrs.push(ai::Info {
71+
addrs.push(rtio::AddrinfoInfo {
7072
address: addr,
7173
family: (*rp).ai_family as uint,
72-
socktype: None,
73-
protocol: None,
74+
socktype: 0,
75+
protocol: 0,
7476
flags: (*rp).ai_flags as uint
7577
});
7678

@@ -96,21 +98,18 @@ extern "system" {
9698

9799
#[cfg(windows)]
98100
fn get_error(_: c_int) -> IoError {
99-
unsafe {
100-
IoError::from_errno(WSAGetLastError() as uint, true)
101-
}
101+
net::last_error()
102102
}
103103

104104
#[cfg(not(windows))]
105105
fn get_error(s: c_int) -> IoError {
106-
use std::io;
107106

108107
let err_str = unsafe {
109108
CString::new(gai_strerror(s), false).as_str().unwrap().to_string()
110109
};
111110
IoError {
112-
kind: io::OtherIoError,
113-
desc: "unable to resolve host",
111+
code: s as uint,
112+
extra: 0,
114113
detail: Some(err_str),
115114
}
116115
}

0 commit comments

Comments
 (0)