Merge branch 'v0.6.x' into master
This commit is contained in:
commit
ab099cb5e1
21
CHANGELOG.md
21
CHANGELOG.md
@ -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)
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
trigger: ["master"]
|
||||
pr: ["master"]
|
||||
trigger: ["master", "v0.6.x"]
|
||||
pr: ["master", "v0.6.x"]
|
||||
|
||||
jobs:
|
||||
# Check formatting
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
///
|
||||
@ -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))
|
||||
|
||||
@ -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;
|
||||
|
||||
70
test/test_tcp_shutdown.rs
Normal file
70
test/test_tcp_shutdown.rs
Normal file
@ -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);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user