From 8e800951df553695bf7ba6af2e97a45e1c535e54 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Tue, 13 Feb 2018 12:49:15 -0700 Subject: [PATCH] Fix TcpStream::wait_timeout POLLOUT is 0x4 and PULLHUP is 0x10 on every other platform, except for the 3DS where they're switched around because Nintendo --- ctr-std/src/sys/unix/net.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctr-std/src/sys/unix/net.rs b/ctr-std/src/sys/unix/net.rs index b41dc1f..a056aec 100644 --- a/ctr-std/src/sys/unix/net.rs +++ b/ctr-std/src/sys/unix/net.rs @@ -143,7 +143,7 @@ impl Socket { let mut pollfd = libc::pollfd { fd: self.0.raw(), - events: libc::POLLOUT, + events: 0x10, //libc::POLLOUT; value in the `libc` crate is currently incorrect revents: 0, }; @@ -181,7 +181,9 @@ impl Socket { _ => { // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look // for POLLHUP rather than read readiness - if pollfd.revents & libc::POLLHUP != 0 { + // + // libc::POLLHUP should be 0x4. the `libc` crate incorrectly lists it as 0x10 + if pollfd.revents & 0x4 != 0 { let e = self.take_error()? .unwrap_or_else(|| { io::Error::new(io::ErrorKind::Other, "no error set after POLLHUP")