From 382f7a12804fc0781a969bdbb9bea9f48e73cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 29 Jul 2015 17:53:08 +0100 Subject: Use latest released versions of bytes and mio and fix build --- Cargo.toml | 11 +++++++++-- src/main.rs | 13 +++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4f54885..b3fe327 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,13 @@ name = "ptp-clock-reflector" version = "0.1.0" authors = ["Sebastian Dröge "] -[dependencies.mio] -git = "https://github.com/carllerche/mio" +[dependencies] +mio = "0.4.1" +bytes = "0.2.10" + +#[dependencies.bytes] +#git = "https://github.com/carllerche/bytes" + +#[dependencies.mio] +#git = "https://github.com/carllerche/mio" diff --git a/src/main.rs b/src/main.rs index e218ab0..81de114 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,10 +17,11 @@ * Boston, MA 02110-1301, USA. */ +extern crate bytes; extern crate mio; +use bytes::{ByteBuf}; use mio::*; -use mio::buf::{ByteBuf}; use mio::udp::*; use std::net::{SocketAddr}; use std::ops::{Range}; @@ -55,7 +56,7 @@ impl PtpReflectorHandler { let event_bind_addr = "0.0.0.0:319".parse().unwrap(); let event_socket = try!(UdpSocket::bound(&event_bind_addr).map_err(|e| e.to_string())); try!(event_socket.join_multicast(&multicast_group).map_err(|e|e.to_string())); - try!(event_loop.register_opt(&event_socket, SOCKET_EVENT, Interest::readable(), PollOpt::level()).map_err(|e| e.to_string())); + try!(event_loop.register_opt(&event_socket, SOCKET_EVENT, EventSet::readable(), PollOpt::level()).map_err(|e| e.to_string())); // FIXME: How can we create this from the multicast group? //let event_addr = SocketAddr::new(multicast_group, 319); @@ -64,7 +65,7 @@ impl PtpReflectorHandler { let general_bind_addr = "0.0.0.0:320".parse().unwrap(); let general_socket = try!(UdpSocket::bound(&general_bind_addr).map_err(|e| e.to_string())); try!(general_socket.join_multicast(&multicast_group).map_err(|e|e.to_string())); - try!(event_loop.register_opt(&general_socket, SOCKET_GENERAL, Interest::readable(), PollOpt::level()).map_err(|e| e.to_string())); + try!(event_loop.register_opt(&general_socket, SOCKET_GENERAL, EventSet::readable(), PollOpt::level()).map_err(|e| e.to_string())); // FIXME: How can we create this from the multicast group? //let general_addr = SocketAddr::new(multicast_group, 320); @@ -83,7 +84,11 @@ impl Handler for PtpReflectorHandler { type Timeout = usize; type Message = (); - fn readable(&mut self, _: &mut EventLoop, token: Token, _: ReadHint) { + fn ready(&mut self, _: &mut EventLoop, token: Token, events: EventSet) { + if !events.is_readable() { + return; + } + let (socket, addr) = match token { SOCKET_EVENT => (&self.event_socket, &self.event_addr), SOCKET_GENERAL => (&self.general_socket, &self.general_addr), -- cgit v0.11.2-2-gd1dd