Handle fallout in io::net::addrinfo, io::process, and rt::rtio
API Changes: - get_host_addresses() returns IoResult<Vec<IpAddr>> - Process.extra_io is Vec<Option<io::PipeStream>>
This commit is contained in:
parent
f340fb9b12
commit
cc42b61936
@ -24,7 +24,7 @@ use io::IoResult;
|
||||
use io::net::ip::{SocketAddr, IpAddr};
|
||||
use option::{Option, Some, None};
|
||||
use rt::rtio::{IoFactory, LocalIo};
|
||||
use slice::OwnedVector;
|
||||
use vec::Vec;
|
||||
|
||||
/// Hints to the types of sockets that are desired when looking up hosts
|
||||
pub enum SocketType {
|
||||
@ -73,7 +73,7 @@ pub struct Info {
|
||||
|
||||
/// Easy name resolution. Given a hostname, returns the list of IP addresses for
|
||||
/// that hostname.
|
||||
pub fn get_host_addresses(host: &str) -> IoResult<~[IpAddr]> {
|
||||
pub fn get_host_addresses(host: &str) -> IoResult<Vec<IpAddr>> {
|
||||
lookup(Some(host), None, None).map(|a| a.move_iter().map(|i| i.address.ip).collect())
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ pub fn get_host_addresses(host: &str) -> IoResult<~[IpAddr]> {
|
||||
/// FIXME: this is not public because the `Hint` structure is not ready for public
|
||||
/// consumption just yet.
|
||||
fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
|
||||
-> IoResult<~[Info]> {
|
||||
-> IoResult<Vec<Info>> {
|
||||
LocalIo::maybe_raise(|io| io.get_host_addresses(hostname, servname, hint))
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ pub struct Process {
|
||||
|
||||
/// Extra I/O handles as configured by the original `ProcessConfig` when
|
||||
/// this process was created. This is by default empty.
|
||||
pub extra_io: ~[Option<io::PipeStream>],
|
||||
pub extra_io: Vec<Option<io::PipeStream>>,
|
||||
}
|
||||
|
||||
/// This configuration describes how a new process should be spawned. A blank
|
||||
@ -418,7 +418,7 @@ impl Drop for Process {
|
||||
drop(self.stdin.take());
|
||||
drop(self.stdout.take());
|
||||
drop(self.stderr.take());
|
||||
drop(mem::replace(&mut self.extra_io, box []));
|
||||
drop(mem::replace(&mut self.extra_io, Vec::new()));
|
||||
|
||||
self.wait();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ pub trait IoFactory {
|
||||
fn unix_connect(&mut self, path: &CString,
|
||||
timeout: Option<u64>) -> IoResult<Box<RtioPipe:Send>>;
|
||||
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
|
||||
hint: Option<ai::Hint>) -> IoResult<~[ai::Info]>;
|
||||
hint: Option<ai::Hint>) -> IoResult<Vec<ai::Info>>;
|
||||
|
||||
// filesystem operations
|
||||
fn fs_from_raw_fd(&mut self, fd: c_int, close: CloseBehavior)
|
||||
|
Loading…
Reference in New Issue
Block a user