diff options
Diffstat (limited to 'src/linux/epoll.rs')
-rw-r--r-- | src/linux/epoll.rs | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/linux/epoll.rs b/src/linux/epoll.rs index b8e9b7b..c68d1f9 100644 --- a/src/linux/epoll.rs +++ b/src/linux/epoll.rs @@ -19,6 +19,7 @@ use libc::{ use crate::syscall::SyscallReturnCode; /// Wrapper over `EPOLL_CTL_*` operations that can be performed on a file descriptor. +#[derive(Debug)] #[repr(i32)] pub enum ControlOperation { /// Add a file descriptor to the interest list. @@ -385,20 +386,12 @@ mod tests { // For EPOLL_CTL_ADD behavior we will try to add some fds with different event masks into // the interest list of epoll instance. assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Add, event_fd_1.as_raw_fd(), event_1) .is_ok()); // We can't add twice the same fd to epoll interest list. assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Add, event_fd_1.as_raw_fd(), event_1) .is_err()); let event_fd_2 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); @@ -406,7 +399,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Add, - event_fd_2.as_raw_fd() as i32, + event_fd_2.as_raw_fd(), // For this fd, we want an Event instance that has `data` field set to other // value than the value of the fd and `events` without EPOLLIN type set. EpollEvent::new(EventSet::OUT, 10) @@ -419,11 +412,7 @@ mod tests { let event_fd_3 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); let event_3 = EpollEvent::new(EventSet::OUT | EventSet::IN, event_fd_3.as_raw_fd() as u64); assert!(epoll - .ctl( - ControlOperation::Add, - event_fd_3.as_raw_fd() as i32, - event_3 - ) + .ctl(ControlOperation::Add, event_fd_3.as_raw_fd(), event_3) .is_ok()); // Let's check `epoll_wait()` behavior for our epoll instance. @@ -457,11 +446,7 @@ mod tests { // that we want to monitor this time on event_fd_1. event_1 = EpollEvent::new(EventSet::OUT, 20); assert!(epoll - .ctl( - ControlOperation::Modify, - event_fd_1.as_raw_fd() as i32, - event_1 - ) + .ctl(ControlOperation::Modify, event_fd_1.as_raw_fd(), event_1) .is_ok()); let event_fd_4 = EventFd::new(libc::EFD_NONBLOCK).unwrap(); @@ -469,7 +454,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Modify, - event_fd_4.as_raw_fd() as i32, + event_fd_4.as_raw_fd(), EpollEvent::default() ) .is_err()); @@ -485,7 +470,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Modify, - event_fd_1.as_raw_fd() as i32, + event_fd_1.as_raw_fd(), EpollEvent::default() ) .is_ok()); @@ -498,7 +483,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Delete, - event_fd_2.as_raw_fd() as i32, + event_fd_2.as_raw_fd(), EpollEvent::default() ) .is_ok()); @@ -514,7 +499,7 @@ mod tests { assert!(epoll .ctl( ControlOperation::Delete, - event_fd_4.as_raw_fd() as i32, + event_fd_4.as_raw_fd(), EpollEvent::default() ) .is_err()); |