summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2017-12-02 05:52:34 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2017-12-02 05:52:34 +0000
commitd374a1ecd3f69027a2ce28e87806f459ef3f9105 (patch)
tree49d50662b5baf35458f1ef271eff0bf830e45032 /src
parentedf1bacba11a00894a035438cf4f0c14c9e495c9 (diff)
parent54313a7a9318294bf22f4640476fb1195ec301f6 (diff)
downloadnix-d374a1ecd3f69027a2ce28e87806f459ef3f9105.zip
Merge #805
805: Fix epoll bug in release mode on Rust 1.20+ r=Susurrus a=Susurrus Seems to have occurred within a Rust release after 1.13, so let's test all of them since then!
Diffstat (limited to 'src')
-rw-r--r--src/sys/epoll.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 5ab766dc..5d63e82f 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -65,16 +65,6 @@ impl EpollEvent {
}
}
-impl<'a> Into<&'a mut EpollEvent> for Option<&'a mut EpollEvent> {
- #[inline]
- fn into(self) -> &'a mut EpollEvent {
- match self {
- Some(epoll_event) => epoll_event,
- None => unsafe { &mut *ptr::null_mut::<EpollEvent>() }
- }
- }
-}
-
#[inline]
pub fn epoll_create() -> Result<RawFd> {
let res = unsafe { libc::epoll_create(1024) };
@@ -91,13 +81,19 @@ pub fn epoll_create1(flags: EpollCreateFlags) -> Result<RawFd> {
#[inline]
pub fn epoll_ctl<'a, T>(epfd: RawFd, op: EpollOp, fd: RawFd, event: T) -> Result<()>
- where T: Into<&'a mut EpollEvent>
+ where T: Into<Option<&'a mut EpollEvent>>
{
- let event: &mut EpollEvent = event.into();
- if event as *const EpollEvent == ptr::null() && op != EpollOp::EpollCtlDel {
+ let mut event: Option<&mut EpollEvent> = event.into();
+ if event.is_none() && op != EpollOp::EpollCtlDel {
Err(Error::Sys(Errno::EINVAL))
} else {
- let res = unsafe { libc::epoll_ctl(epfd, op as c_int, fd, &mut event.event) };
+ let res = unsafe {
+ if let Some(ref mut event) = event {
+ libc::epoll_ctl(epfd, op as c_int, fd, &mut event.event)
+ } else {
+ libc::epoll_ctl(epfd, op as c_int, fd, ptr::null_mut())
+ }
+ };
Errno::result(res).map(drop)
}
}