Skip to content

Commit 6c07265

Browse files
committed
---
yaml --- r: 152348 b: refs/heads/try2 c: 550c347 h: refs/heads/master v: v3
1 parent ac7604c commit 6c07265

File tree

15 files changed

+320
-547
lines changed

15 files changed

+320
-547
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: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 51348b068b88d71426d9de93762575cd2bb9a5f5
8+
refs/heads/try2: 550c347d7b9fbeb10dcf039f0e7e0c16de83dc4a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustuv/addrinfo.rs

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
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_int;
1312
use libc;
1413
use std::mem;
1514
use std::ptr::null;
1615
use std::rt::task::BlockedTask;
16+
use std::rt::rtio;
1717

1818
use net;
1919
use super::{Loop, UvError, Request, wait_until_woken_after, wakeup};
@@ -33,7 +33,9 @@ pub struct GetAddrInfoRequest;
3333

3434
impl GetAddrInfoRequest {
3535
pub fn run(loop_: &Loop, node: Option<&str>, service: Option<&str>,
36-
hints: Option<ai::Hint>) -> Result<Vec<ai::Info>, UvError> {
36+
hints: Option<rtio::AddrinfoHint>)
37+
-> Result<Vec<rtio::AddrinfoInfo>, UvError>
38+
{
3739
assert!(node.is_some() || service.is_some());
3840
let (_c_node, c_node_ptr) = match node {
3941
Some(n) => {
@@ -54,20 +56,11 @@ impl GetAddrInfoRequest {
5456
};
5557

5658
let hint = hints.map(|hint| {
57-
let mut flags = 0;
58-
each_ai_flag(|cval, aival| {
59-
if hint.flags & (aival as uint) != 0 {
60-
flags |= cval as i32;
61-
}
62-
});
63-
let socktype = 0;
64-
let protocol = 0;
65-
6659
libc::addrinfo {
67-
ai_flags: flags,
60+
ai_flags: 0,
6861
ai_family: hint.family as c_int,
69-
ai_socktype: socktype,
70-
ai_protocol: protocol,
62+
ai_socktype: 0,
63+
ai_protocol: 0,
7164
ai_addrlen: 0,
7265
ai_canonname: null(),
7366
ai_addr: null(),
@@ -119,22 +112,8 @@ impl Drop for Addrinfo {
119112
}
120113
}
121114

122-
fn each_ai_flag(_f: |c_int, ai::Flag|) {
123-
/* FIXME: do we really want to support these?
124-
unsafe {
125-
f(uvll::rust_AI_ADDRCONFIG(), ai::AddrConfig);
126-
f(uvll::rust_AI_ALL(), ai::All);
127-
f(uvll::rust_AI_CANONNAME(), ai::CanonName);
128-
f(uvll::rust_AI_NUMERICHOST(), ai::NumericHost);
129-
f(uvll::rust_AI_NUMERICSERV(), ai::NumericServ);
130-
f(uvll::rust_AI_PASSIVE(), ai::Passive);
131-
f(uvll::rust_AI_V4MAPPED(), ai::V4Mapped);
132-
}
133-
*/
134-
}
135-
136115
// Traverse the addrinfo linked list, producing a vector of Rust socket addresses
137-
pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<ai::Info> {
116+
pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<rtio::AddrinfoInfo> {
138117
unsafe {
139118
let mut addr = addr.handle;
140119

@@ -143,35 +122,12 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<ai::Info> {
143122
let rustaddr = net::sockaddr_to_addr(mem::transmute((*addr).ai_addr),
144123
(*addr).ai_addrlen as uint);
145124

146-
let mut flags = 0;
147-
each_ai_flag(|cval, aival| {
148-
if (*addr).ai_flags & cval != 0 {
149-
flags |= aival as uint;
150-
}
151-
});
152-
153-
/* FIXME: do we really want to support these
154-
let protocol = match (*addr).ai_protocol {
155-
p if p == uvll::rust_IPPROTO_UDP() => Some(ai::UDP),
156-
p if p == uvll::rust_IPPROTO_TCP() => Some(ai::TCP),
157-
_ => None,
158-
};
159-
let socktype = match (*addr).ai_socktype {
160-
p if p == uvll::rust_SOCK_STREAM() => Some(ai::Stream),
161-
p if p == uvll::rust_SOCK_DGRAM() => Some(ai::Datagram),
162-
p if p == uvll::rust_SOCK_RAW() => Some(ai::Raw),
163-
_ => None,
164-
};
165-
*/
166-
let protocol = None;
167-
let socktype = None;
168-
169-
addrs.push(ai::Info {
125+
addrs.push(rtio::AddrinfoInfo {
170126
address: rustaddr,
171127
family: (*addr).ai_family as uint,
172-
socktype: socktype,
173-
protocol: protocol,
174-
flags: flags,
128+
socktype: 0,
129+
protocol: 0,
130+
flags: 0,
175131
});
176132
if (*addr).ai_next.is_not_null() {
177133
addr = (*addr).ai_next;

branches/try2/src/librustuv/async.rs

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

11+
use alloc::arc::Arc;
1112
use std::mem;
13+
use std::rt::exclusive::Exclusive;
1214
use std::rt::rtio::{Callback, RemoteCallback};
13-
use std::unstable::sync::Exclusive;
1415

1516
use uvll;
1617
use super::{Loop, UvHandle};
@@ -22,12 +23,12 @@ pub struct AsyncWatcher {
2223

2324
// A flag to tell the callback to exit, set from the dtor. This is
2425
// almost never contested - only in rare races with the dtor.
25-
exit_flag: Exclusive<bool>
26+
exit_flag: Arc<Exclusive<bool>>,
2627
}
2728

2829
struct Payload {
2930
callback: Box<Callback:Send>,
30-
exit_flag: Exclusive<bool>,
31+
exit_flag: Arc<Exclusive<bool>>,
3132
}
3233

3334
impl AsyncWatcher {
@@ -36,7 +37,7 @@ impl AsyncWatcher {
3637
assert_eq!(unsafe {
3738
uvll::uv_async_init(loop_.handle, handle, async_cb)
3839
}, 0);
39-
let flag = Exclusive::new(false);
40+
let flag = Arc::new(Exclusive::new(false));
4041
let payload = box Payload { callback: cb, exit_flag: flag.clone() };
4142
unsafe {
4243
let payload: *u8 = mem::transmute(payload);
@@ -80,9 +81,7 @@ extern fn async_cb(handle: *uvll::uv_async_t) {
8081
// could be called in the other thread, missing the final
8182
// callback while still destroying the handle.
8283

83-
let should_exit = unsafe {
84-
payload.exit_flag.with_imm(|&should_exit| should_exit)
85-
};
84+
let should_exit = unsafe { *payload.exit_flag.lock() };
8685

8786
payload.callback.call();
8887

@@ -108,16 +107,13 @@ impl RemoteCallback for AsyncWatcher {
108107

109108
impl Drop for AsyncWatcher {
110109
fn drop(&mut self) {
111-
unsafe {
112-
self.exit_flag.with(|should_exit| {
113-
// NB: These two things need to happen atomically. Otherwise
114-
// the event handler could wake up due to a *previous*
115-
// signal and see the exit flag, destroying the handle
116-
// before the final send.
117-
*should_exit = true;
118-
uvll::uv_async_send(self.handle)
119-
})
120-
}
110+
let mut should_exit = unsafe { self.exit_flag.lock() };
111+
// NB: These two things need to happen atomically. Otherwise
112+
// the event handler could wake up due to a *previous*
113+
// signal and see the exit flag, destroying the handle
114+
// before the final send.
115+
*should_exit = true;
116+
unsafe { uvll::uv_async_send(self.handle) }
121117
}
122118
}
123119

0 commit comments

Comments
 (0)