Skip to content

Commit

Permalink
Merge branch 'v0.6.x' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed May 28, 2019
2 parents 756bf28 + 5247496 commit ab099cb
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 21 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
`Ipv4Addr` arguments by value rather than by reference.
* Fix lazycell related compilation issues.

# 0.6.19 (May 28, 2018)

### Fixed
- Do not trigger HUP events on kqueue platforms (#958).

# 0.6.18 (May 24, 2018)

### Fixed
- Fix compilation on kqueue platforms with 32bit C long (#948).

# 0.6.17 (May 15, 2018)

### Fixed
- Don't report `RDHUP` as `HUP` (#939)
- Fix lazycell related compilation issues.
- Fix EPOLLPRI conflicting with READABLE
- Abort process on ref count overflows

### Added
- Define PRI on all targets

# 0.6.16 (September 5, 2018)

* Add EPOLLPRI readiness to UnixReady on supported platforms (#867)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "0.7.0"
license = "MIT"
authors = ["Carl Lerche <me@carllerche.com>"]
description = "Lightweight non-blocking IO"
documentation = "https://docs.rs/mio/0.6.16/mio/"
documentation = "https://docs.rs/mio/0.7.0/mio/"
homepage = "https://github.com/tokio-rs/mio"
repository = "https://github.com/tokio-rs/mio"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
trigger: ["master"]
pr: ["master"]
trigger: ["master", "v0.6.x"]
pr: ["master", "v0.6.x"]

jobs:
# Check formatting
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/mio/0.6.16")]
#![doc(html_root_url = "https://docs.rs/mio/0.7.0")]
#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![cfg_attr(test, deny(warnings))]
// Many of mio's public methods violate this lint, but they can't be fixed
Expand Down
8 changes: 2 additions & 6 deletions src/sys/unix/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::sys::unix::io::set_cloexec;
use crate::sys::unix::{cvt, UnixReady};
use crate::{io, Interests, PollOpt, Ready, Token};
use libc::{self, c_int};
use libc::{EPOLLERR, EPOLLHUP, EPOLLONESHOT, EPOLLRDHUP};
use libc::{EPOLLERR, EPOLLHUP, EPOLLONESHOT};
use libc::{EPOLLET, EPOLLIN, EPOLLOUT, EPOLLPRI};
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
Expand Down Expand Up @@ -190,10 +190,6 @@ fn ready_to_epoll(interest: Ready, opts: PollOpt) -> u32 {
kind |= EPOLLOUT;
}

if UnixReady::from(interest).is_hup() {
kind |= EPOLLRDHUP;
}

if UnixReady::from(interest).is_priority() {
kind |= EPOLLPRI;
}
Expand Down Expand Up @@ -276,7 +272,7 @@ impl Events {
kind = kind | UnixReady::error();
}

if (epoll & EPOLLRDHUP) != 0 || (epoll & EPOLLHUP) != 0 {
if (epoll & EPOLLHUP) != 0 {
kind = kind | UnixReady::hup();
}

Expand Down
10 changes: 0 additions & 10 deletions src/sys/unix/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,6 @@ impl Events {
event::kind_mut(&mut self.events[idx]).insert(UnixReady::lio());
}
}

if e.flags & libc::EV_EOF != 0 {
event::kind_mut(&mut self.events[idx]).insert(UnixReady::hup());

// When the read end of the socket is closed, EV_EOF is set on
// flags, and fflags contains the error if there is one.
if e.fflags != 0 {
event::kind_mut(&mut self.events[idx]).insert(UnixReady::error());
}
}
}

ret
Expand Down
4 changes: 3 additions & 1 deletion src/sys/unix/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl UnixReady {
/// **Note that only readable and writable readiness is guaranteed to be
/// supported on all platforms**. This means that `hup` readiness
/// should be treated as a hint. For more details, see [readiness] in the
/// poll documentation.
/// poll documentation. It is also unclear if HUP readiness will remain in 0.7. See
/// [here][issue-941].
///
/// See [`Poll`] for more documentation on polling.
///
Expand All @@ -217,6 +218,7 @@ impl UnixReady {
///
/// [`Poll`]: ../struct.Poll.html
/// [readiness]: ../struct.Poll.html#readiness-operations
/// [issue-941]: https://github.com/tokio-rs/mio/issues/941
#[inline]
pub fn hup() -> UnixReady {
UnixReady(ready_from_usize(HUP))
Expand Down
1 change: 1 addition & 0 deletions test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod test_reregister_without_poll;
mod test_smoke;
mod test_tcp;
mod test_tcp_level;
mod test_tcp_shutdown;
mod test_udp_level;
mod test_udp_socket;
mod test_write_then_drop;
Expand Down
70 changes: 70 additions & 0 deletions test/test_tcp_shutdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
use std::net::Shutdown;
use std::time::Duration;

use mio::net::TcpStream;
use mio::{Events, Interests, Poll, PollOpt, Token};

macro_rules! wait {
($poll:ident, $ready:ident) => {{
use std::time::Instant;

let now = Instant::now();
let mut events = Events::with_capacity(16);
let mut found = false;

while !found {
if now.elapsed() > Duration::from_secs(5) {
panic!("not ready");
}

$poll
.poll(&mut events, Some(Duration::from_secs(1)))
.unwrap();

for event in &events {
#[cfg(unix)]
{
use mio::unix::UnixReady;
assert!(!UnixReady::from(event.readiness()).is_hup());
}

if event.token() == Token(0) && event.readiness().$ready() {
found = true;
break;
}
}
}
}};
}

#[test]
fn test_write_shutdown() {
let mut poll = Poll::new().unwrap();

let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();

let interests = Interests::readable() | Interests::writable();

let client = TcpStream::connect(&addr).unwrap();
poll.registry()
.register(&client, Token(0), interests, PollOpt::edge())
.unwrap();

let (socket, _) = listener.accept().unwrap();

wait!(poll, is_writable);

let mut events = Events::with_capacity(16);

// Polling should not have any events
poll.poll(&mut events, Some(Duration::from_millis(100)))
.unwrap();
assert!(events.iter().next().is_none());

println!("SHUTTING DOWN");
// Now, shutdown the write half of the socket.
socket.shutdown(Shutdown::Write).unwrap();

wait!(poll, is_readable);
}

0 comments on commit ab099cb

Please sign in to comment.