Assorted test fixes and merge conflicts

This commit is contained in:
Alex Crichton 2013-11-05 23:29:11 -08:00
parent b545751597
commit 5e6bbc6bfa
8 changed files with 134 additions and 144 deletions

View File

@ -95,27 +95,6 @@ impl FsRequest {
}
}
pub fn close(loop_: &Loop, fd: c_int, sync: bool) -> Result<(), UvError> {
if sync {
execute_nop(|req, cb| unsafe {
uvll::uv_fs_close(loop_.handle, req, fd, cb)
})
} else {
unsafe {
let req = uvll::malloc_req(uvll::UV_FS);
uvll::uv_fs_close(loop_.handle, req, fd, close_cb);
return Ok(());
}
extern fn close_cb(req: *uvll::uv_fs_t) {
unsafe {
uvll::uv_fs_req_cleanup(req);
uvll::free_req(req);
}
}
}
}
pub fn mkdir(loop_: &Loop, path: &CString, mode: c_int)
-> Result<(), UvError>
{
@ -240,10 +219,12 @@ impl FsRequest {
pub fn utime(loop_: &Loop, path: &CString, atime: u64, mtime: u64)
-> Result<(), UvError>
{
// libuv takes seconds
let atime = atime as libc::c_double / 1000.0;
let mtime = mtime as libc::c_double / 1000.0;
execute_nop(|req, cb| unsafe {
uvll::uv_fs_utime(loop_.handle, req, path.with_ref(|p| p),
atime as libc::c_double, mtime as libc::c_double,
cb)
atime, mtime, cb)
})
}
@ -368,12 +349,12 @@ impl FileWatcher {
}
fn base_read(&mut self, buf: &mut [u8], offset: i64) -> Result<int, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
let r = FsRequest::read(&self.loop_, self.fd, buf, offset);
r.map_err(uv_error_to_io_error)
}
fn base_write(&mut self, buf: &[u8], offset: i64) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
let r = FsRequest::write(&self.loop_, self.fd, buf, offset);
r.map_err(uv_error_to_io_error)
}
@ -397,14 +378,26 @@ impl FileWatcher {
impl Drop for FileWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
match self.close {
rtio::DontClose => {}
rtio::CloseAsynchronously => {
FsRequest::close(&self.loop_, self.fd, false);
unsafe {
let req = uvll::malloc_req(uvll::UV_FS);
uvll::uv_fs_close(self.loop_.handle, req, self.fd, close_cb);
}
extern fn close_cb(req: *uvll::uv_fs_t) {
unsafe {
uvll::uv_fs_req_cleanup(req);
uvll::free_req(req);
}
}
}
rtio::CloseSynchronously => {
FsRequest::close(&self.loop_, self.fd, true);
execute_nop(|req, cb| unsafe {
uvll::uv_fs_close(self.loop_.handle, req, self.fd, cb)
});
}
}
}
@ -439,15 +432,15 @@ impl rtio::RtioFileStream for FileWatcher {
self_.seek_common(0, SEEK_CUR)
}
fn fsync(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
FsRequest::fsync(&self.loop_, self.fd).map_err(uv_error_to_io_error)
}
fn datasync(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
FsRequest::datasync(&self.loop_, self.fd).map_err(uv_error_to_io_error)
}
fn truncate(&mut self, offset: i64) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
let r = FsRequest::truncate(&self.loop_, self.fd, offset);
r.map_err(uv_error_to_io_error)
}
@ -482,10 +475,6 @@ mod test {
// write
let result = FsRequest::write(l, fd, "hello".as_bytes(), -1);
assert!(result.is_ok());
// close
let result = FsRequest::close(l, fd, true);
assert!(result.is_ok());
}
{
@ -505,15 +494,10 @@ mod test {
assert!(nread > 0);
let read_str = str::from_utf8(read_mem.slice(0, nread as uint));
assert_eq!(read_str, ~"hello");
// close
let result = FsRequest::close(l, fd, true);
assert!(result.is_ok());
// unlink
let result = FsRequest::unlink(l, &path_str.to_c_str());
assert!(result.is_ok());
}
// unlink
let result = FsRequest::unlink(l, &path_str.to_c_str());
assert!(result.is_ok());
}
}
@ -570,12 +554,14 @@ mod test {
let path = &"./tmp/double_create_dir".to_c_str();
let mode = S_IWUSR | S_IRUSR;
let result = FsRequest::stat(l, path);
assert!(result.is_err(), "{:?}", result);
let result = FsRequest::mkdir(l, path, mode as c_int);
assert!(result.is_ok());
assert!(result.is_ok(), "{:?}", result);
let result = FsRequest::mkdir(l, path, mode as c_int);
assert!(result.is_err());
assert!(result.is_err(), "{:?}", result);
let result = FsRequest::rmdir(l, path);
assert!(result.is_ok());
assert!(result.is_ok(), "{:?}", result);
}
}

View File

@ -259,43 +259,43 @@ impl HomingIO for TcpWatcher {
impl rtio::RtioSocket for TcpWatcher {
fn socket_name(&mut self) -> Result<SocketAddr, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
socket_name(Tcp, self.handle)
}
}
impl rtio::RtioTcpStream for TcpWatcher {
fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.read(buf).map_err(uv_error_to_io_error)
}
fn write(&mut self, buf: &[u8]) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.write(buf).map_err(uv_error_to_io_error)
}
fn peer_name(&mut self) -> Result<SocketAddr, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
socket_name(TcpPeer, self.handle)
}
fn control_congestion(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_nodelay(self.handle, 0 as c_int)
})
}
fn nodelay(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_nodelay(self.handle, 1 as c_int)
})
}
fn keepalive(&mut self, delay_in_seconds: uint) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_keepalive(self.handle, 1 as c_int,
delay_in_seconds as c_uint)
@ -303,7 +303,7 @@ impl rtio::RtioTcpStream for TcpWatcher {
}
fn letdie(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_keepalive(self.handle, 0 as c_int, 0 as c_uint)
})
@ -312,7 +312,7 @@ impl rtio::RtioTcpStream for TcpWatcher {
impl Drop for TcpWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.close();
}
}
@ -356,7 +356,7 @@ impl UvHandle<uvll::uv_tcp_t> for TcpListener {
impl rtio::RtioSocket for TcpListener {
fn socket_name(&mut self) -> Result<SocketAddr, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
socket_name(Tcp, self.handle)
}
}
@ -370,7 +370,7 @@ impl rtio::RtioTcpListener for TcpListener {
incoming: incoming,
};
let _m = acceptor.fire_missiles();
let _m = acceptor.fire_homing_missile();
// XXX: the 128 backlog should be configurable
match unsafe { uvll::uv_listen(acceptor.listener.handle, 128, listen_cb) } {
0 => Ok(acceptor as ~rtio::RtioTcpAcceptor),
@ -399,7 +399,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: c_int) {
impl Drop for TcpListener {
fn drop(&mut self) {
let (_m, sched) = self.fire_missiles_sched();
let (_m, sched) = self.fire_homing_missile_sched();
do sched.deschedule_running_task_and_then |_, task| {
self.closing_task = Some(task);
@ -424,26 +424,26 @@ impl HomingIO for TcpAcceptor {
impl rtio::RtioSocket for TcpAcceptor {
fn socket_name(&mut self) -> Result<SocketAddr, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
socket_name(Tcp, self.listener.handle)
}
}
impl rtio::RtioTcpAcceptor for TcpAcceptor {
fn accept(&mut self) -> Result<~rtio::RtioTcpStream, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.incoming.recv()
}
fn accept_simultaneously(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_simultaneous_accepts(self.listener.handle, 1)
})
}
fn dont_accept_simultaneously(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_tcp_simultaneous_accepts(self.listener.handle, 0)
})
@ -489,7 +489,7 @@ impl HomingIO for UdpWatcher {
impl rtio::RtioSocket for UdpWatcher {
fn socket_name(&mut self) -> Result<SocketAddr, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
socket_name(Udp, self.handle)
}
}
@ -503,7 +503,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
buf: Option<Buf>,
result: Option<(ssize_t, SocketAddr)>,
}
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
return match unsafe {
uvll::uv_udp_recv_start(self.handle, alloc_cb, recv_cb)
@ -564,7 +564,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
fn sendto(&mut self, buf: &[u8], dst: SocketAddr) -> Result<(), IoError> {
struct Ctx { task: Option<BlockedTask>, result: c_int }
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
let req = Request::new(uvll::UV_UDP_SEND);
let buf = slice_to_uv_buf(buf);
@ -607,7 +607,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn join_multicast(&mut self, multi: IpAddr) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
do multi.to_str().with_c_str |m_addr| {
uvll::uv_udp_set_membership(self.handle,
@ -618,7 +618,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn leave_multicast(&mut self, multi: IpAddr) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
do multi.to_str().with_c_str |m_addr| {
uvll::uv_udp_set_membership(self.handle,
@ -629,7 +629,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn loop_multicast_locally(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_multicast_loop(self.handle,
1 as c_int)
@ -637,7 +637,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn dont_loop_multicast_locally(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_multicast_loop(self.handle,
0 as c_int)
@ -645,7 +645,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn multicast_time_to_live(&mut self, ttl: int) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_multicast_ttl(self.handle,
ttl as c_int)
@ -653,14 +653,14 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn time_to_live(&mut self, ttl: int) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_ttl(self.handle, ttl as c_int)
})
}
fn hear_broadcasts(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_broadcast(self.handle,
1 as c_int)
@ -668,7 +668,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
fn ignore_broadcasts(&mut self) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
status_to_io_result(unsafe {
uvll::uv_udp_set_broadcast(self.handle,
0 as c_int)
@ -679,7 +679,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
impl Drop for UdpWatcher {
fn drop(&mut self) {
// Send ourselves home to close this handle (blocking while doing so).
let (_m, sched) = self.fire_missiles_sched();
let (_m, sched) = self.fire_homing_missile_sched();
let mut slot = None;
unsafe {
uvll::set_data_for_uv_handle(self.handle, &slot);
@ -693,6 +693,7 @@ impl Drop for UdpWatcher {
let slot: &mut Option<BlockedTask> = unsafe {
cast::transmute(uvll::get_data_for_uv_handle(handle))
};
unsafe { uvll::free_handle(handle) }
let sched: ~Scheduler = Local::take();
sched.resume_blocked_task_immediately(slot.take_unwrap());
}

View File

@ -26,6 +26,7 @@ use uvll;
pub struct PipeWatcher {
stream: StreamWatcher,
home: SchedHandle,
priv defused: bool,
}
pub struct PipeListener {
@ -43,47 +44,43 @@ pub struct PipeAcceptor {
// PipeWatcher implementation and traits
impl PipeWatcher {
pub fn new(pipe: *uvll::uv_pipe_t) -> PipeWatcher {
PipeWatcher {
stream: StreamWatcher::new(pipe),
home: get_handle_to_current_scheduler!(),
}
}
pub fn alloc(loop_: &Loop, ipc: bool) -> *uvll::uv_pipe_t {
unsafe {
// Creates an uninitialized pipe watcher. The underlying uv pipe is ready to
// get bound to some other source (this is normally a helper method paired
// with another call).
pub fn new(loop_: &Loop, ipc: bool) -> PipeWatcher {
let handle = unsafe {
let handle = uvll::malloc_handle(uvll::UV_NAMED_PIPE);
assert!(!handle.is_null());
let ipc = ipc as libc::c_int;
assert_eq!(uvll::uv_pipe_init(loop_.handle, handle, ipc), 0);
handle
};
PipeWatcher {
stream: StreamWatcher::new(handle),
home: get_handle_to_current_scheduler!(),
defused: false,
}
}
pub fn open(loop_: &Loop, file: libc::c_int) -> Result<PipeWatcher, UvError>
{
let handle = PipeWatcher::alloc(loop_, false);
match unsafe { uvll::uv_pipe_open(handle, file) } {
0 => Ok(PipeWatcher::new(handle)),
n => {
unsafe { uvll::uv_close(handle, pipe_close_cb) }
Err(UvError(n))
}
let pipe = PipeWatcher::new(loop_, false);
match unsafe { uvll::uv_pipe_open(pipe.handle(), file) } {
0 => Ok(pipe),
n => Err(UvError(n))
}
}
pub fn connect(loop_: &Loop, name: &CString) -> Result<PipeWatcher, UvError>
{
struct Ctx {
task: Option<BlockedTask>,
result: Option<Result<PipeWatcher, UvError>>,
}
let mut cx = Ctx { task: None, result: None };
struct Ctx { task: Option<BlockedTask>, result: libc::c_int, }
let mut cx = Ctx { task: None, result: 0 };
let req = Request::new(uvll::UV_CONNECT);
let pipe = PipeWatcher::new(loop_, false);
unsafe {
uvll::set_data_for_req(req.handle, &cx as *Ctx);
uvll::uv_pipe_connect(req.handle,
PipeWatcher::alloc(loop_, false),
pipe.handle(),
name.with_ref(|p| p),
connect_cb)
}
@ -93,38 +90,41 @@ impl PipeWatcher {
do sched.deschedule_running_task_and_then |_, task| {
cx.task = Some(task);
}
assert!(cx.task.is_none());
return cx.result.take().expect("pipe connect needs a result");
return match cx.result {
0 => Ok(pipe),
n => Err(UvError(n))
};
extern fn connect_cb(req: *uvll::uv_connect_t, status: libc::c_int) {
let _req = Request::wrap(req);
if status == uvll::ECANCELED { return }
unsafe {
let cx: &mut Ctx = cast::transmute(uvll::get_data_for_req(req));
let stream = uvll::get_stream_handle_from_connect_req(req);
cx.result = Some(match status {
0 => Ok(PipeWatcher::new(stream)),
n => {
uvll::free_handle(stream);
Err(UvError(n))
}
});
cx.result = status;
let sched: ~Scheduler = Local::take();
sched.resume_blocked_task_immediately(cx.task.take_unwrap());
}
}
}
pub fn handle(&self) -> *uvll::uv_pipe_t { self.stream.handle }
// Unwraps the underlying uv pipe. This cancels destruction of the pipe and
// allows the pipe to get moved elsewhere
fn unwrap(mut self) -> *uvll::uv_pipe_t {
self.defused = true;
return self.stream.handle;
}
}
impl RtioPipe for PipeWatcher {
fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.read(buf).map_err(uv_error_to_io_error)
}
fn write(&mut self, buf: &[u8]) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.write(buf).map_err(uv_error_to_io_error)
}
}
@ -135,8 +135,10 @@ impl HomingIO for PipeWatcher {
impl Drop for PipeWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
self.stream.close();
if !self.defused {
let _m = self.fire_homing_missile();
self.stream.close();
}
}
}
@ -148,21 +150,21 @@ extern fn pipe_close_cb(handle: *uvll::uv_handle_t) {
impl PipeListener {
pub fn bind(loop_: &Loop, name: &CString) -> Result<~PipeListener, UvError> {
let pipe = PipeWatcher::alloc(loop_, false);
match unsafe { uvll::uv_pipe_bind(pipe, name.with_ref(|p| p)) } {
let pipe = PipeWatcher::new(loop_, false);
match unsafe { uvll::uv_pipe_bind(pipe.handle(), name.with_ref(|p| p)) } {
0 => {
// If successful, unwrap the PipeWatcher because we control how
// we close the pipe differently. We can't rely on
// StreamWatcher's default close method.
let p = ~PipeListener {
home: get_handle_to_current_scheduler!(),
pipe: pipe,
pipe: pipe.unwrap(),
closing_task: None,
outgoing: Tube::new(),
};
Ok(p.install())
}
n => {
unsafe { uvll::uv_close(pipe, pipe_close_cb) }
Err(UvError(n))
}
n => Err(UvError(n))
}
}
}
@ -176,7 +178,7 @@ impl RtioUnixListener for PipeListener {
incoming: incoming,
};
let _m = acceptor.fire_missiles();
let _m = acceptor.fire_homing_missile();
// XXX: the 128 backlog should be configurable
match unsafe { uvll::uv_listen(acceptor.listener.pipe, 128, listen_cb) } {
0 => Ok(acceptor as ~RtioUnixAcceptor),
@ -199,9 +201,9 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) {
let loop_ = Loop::wrap(unsafe {
uvll::get_loop_for_uv_handle(server)
});
let client = PipeWatcher::alloc(&loop_, false);
assert_eq!(unsafe { uvll::uv_accept(server, client) }, 0);
Ok(~PipeWatcher::new(client) as ~RtioPipe)
let client = PipeWatcher::new(&loop_, false);
assert_eq!(unsafe { uvll::uv_accept(server, client.handle()) }, 0);
Ok(~client as ~RtioPipe)
}
uvll::ECANCELED => return,
n => Err(uv_error_to_io_error(UvError(n)))
@ -213,7 +215,7 @@ extern fn listen_cb(server: *uvll::uv_stream_t, status: libc::c_int) {
impl Drop for PipeListener {
fn drop(&mut self) {
let (_m, sched) = self.fire_missiles_sched();
let (_m, sched) = self.fire_homing_missile_sched();
do sched.deschedule_running_task_and_then |_, task| {
self.closing_task = Some(task);
@ -234,7 +236,7 @@ extern fn listener_close_cb(handle: *uvll::uv_handle_t) {
impl RtioUnixAcceptor for PipeAcceptor {
fn accept(&mut self) -> Result<~RtioPipe, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.incoming.recv()
}
}

View File

@ -144,10 +144,10 @@ unsafe fn set_stdio(dst: *uvll::uv_stdio_container_t,
if writable {
flags |= uvll::STDIO_WRITABLE_PIPE as libc::c_int;
}
let pipe_handle = PipeWatcher::alloc(loop_, false);
let pipe = PipeWatcher::new(loop_, false);
uvll::set_stdio_container_flags(dst, flags);
uvll::set_stdio_container_stream(dst, pipe_handle);
Some(PipeWatcher::new(pipe_handle))
uvll::set_stdio_container_stream(dst, pipe.handle());
Some(pipe)
}
}
}
@ -204,7 +204,7 @@ impl RtioProcess for Process {
}
fn kill(&mut self, signal: int) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
match unsafe {
uvll::uv_process_kill(self.handle, signal as libc::c_int)
} {
@ -215,7 +215,7 @@ impl RtioProcess for Process {
fn wait(&mut self) -> int {
// Make sure (on the home scheduler) that we have an exit status listed
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
match self.exit_status {
Some(*) => {}
None => {
@ -238,7 +238,7 @@ impl RtioProcess for Process {
impl Drop for Process {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
assert!(self.to_wake.is_none());
self.close_async_();
}

View File

@ -73,7 +73,7 @@ impl RtioSignal for SignalWatcher {}
impl Drop for SignalWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.close_async_();
}
}

View File

@ -66,7 +66,7 @@ impl UvHandle<uvll::uv_timer_t> for TimerWatcher {
impl RtioTimer for TimerWatcher {
fn sleep(&mut self, msecs: u64) {
let (_m, sched) = self.fire_missiles_sched();
let (_m, sched) = self.fire_homing_missile_sched();
do sched.deschedule_running_task_and_then |_sched, task| {
self.action = Some(WakeTask(task));
self.start(msecs, 0);
@ -77,7 +77,7 @@ impl RtioTimer for TimerWatcher {
fn oneshot(&mut self, msecs: u64) -> PortOne<()> {
let (port, chan) = oneshot();
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.action = Some(SendOnce(chan));
self.start(msecs, 0);
@ -87,7 +87,7 @@ impl RtioTimer for TimerWatcher {
fn period(&mut self, msecs: u64) -> Port<()> {
let (port, chan) = stream();
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.action = Some(SendMany(chan));
self.start(msecs, msecs);
@ -113,7 +113,7 @@ extern fn timer_cb(handle: *uvll::uv_timer_t, _status: c_int) {
impl Drop for TimerWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.action = None;
self.stop();
self.close_async_();

View File

@ -54,18 +54,18 @@ impl TtyWatcher {
impl RtioTTY for TtyWatcher {
fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.read(buf).map_err(uv_error_to_io_error)
}
fn write(&mut self, buf: &[u8]) -> Result<(), IoError> {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.write(buf).map_err(uv_error_to_io_error)
}
fn set_raw(&mut self, raw: bool) -> Result<(), IoError> {
let raw = raw as libc::c_int;
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
match unsafe { uvll::uv_tty_set_mode(self.tty, raw) } {
0 => Ok(()),
n => Err(uv_error_to_io_error(UvError(n)))
@ -79,7 +79,7 @@ impl RtioTTY for TtyWatcher {
let widthptr: *libc::c_int = &width;
let heightptr: *libc::c_int = &width;
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
match unsafe { uvll::uv_tty_get_winsize(self.tty,
widthptr, heightptr) } {
0 => Ok((width as int, height as int)),
@ -102,7 +102,7 @@ impl HomingIO for TtyWatcher {
impl Drop for TtyWatcher {
fn drop(&mut self) {
let _m = self.fire_missiles();
let _m = self.fire_homing_missile();
self.stream.close();
}
}

View File

@ -589,7 +589,8 @@ pub fn rmdir_recursive(path: &Path) {
/// Changes the timestamps for a file's last modification and access time.
/// The file at the path specified will have its last access time set to
/// `atime` and its modification time set to `mtime`.
/// `atime` and its modification time set to `mtime`. The times specified should
/// be in milliseconds.
///
/// # Errors
///
@ -1266,9 +1267,9 @@ mod test {
let path = tmpdir.join("a");
File::create(&path);
change_file_times(&path, 100, 200);
assert_eq!(path.stat().accessed, 100);
assert_eq!(path.stat().modified, 200);
change_file_times(&path, 1000, 2000);
assert_eq!(path.stat().accessed, 1000);
assert_eq!(path.stat().modified, 2000);
rmdir_recursive(&tmpdir);
}