From 1b498e8aa23b53528a5a2d6e6aad2fe41f37ff60 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 24 May 2019 14:08:07 -0700 Subject: [PATCH] Fix TCP poll_hup test (#1106) This updates tests to track a fix applied in Mio. Previously, Mio incorrectly fired HUP events. This was due to Mio mapping `RDHUP` to HUP. The test is updated to correctly generate a HUP event. Additionally, HUP events will be removed from all platforms except for Linux. This is caused by the inability to reliably map kqueue events to the epoll HUP behavior. --- ci/azure-cross-compile.yml | 3 +++ tokio-tcp/Cargo.toml | 1 + tokio-tcp/tests/tcp.rs | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ci/azure-cross-compile.yml b/ci/azure-cross-compile.yml index 857aeb944..8c2553c72 100644 --- a/ci/azure-cross-compile.yml +++ b/ci/azure-cross-compile.yml @@ -8,6 +8,9 @@ jobs: parameters: rust_version: stable + - script: sudo apt-get update + displayName: "apt-get update" + - script: sudo apt-get install gcc-multilib displayName: "Install gcc-multilib" diff --git a/tokio-tcp/Cargo.toml b/tokio-tcp/Cargo.toml index 5e87b9b9d..55f3e43e8 100644 --- a/tokio-tcp/Cargo.toml +++ b/tokio-tcp/Cargo.toml @@ -31,4 +31,5 @@ futures = "0.1.19" [dev-dependencies] env_logger = { version = "0.5", default-features = false } +net2 = "*" tokio = { version = "0.2.0", path = "../tokio" } diff --git a/tokio-tcp/tests/tcp.rs b/tokio-tcp/tests/tcp.rs index 48a0ffd48..b35baf464 100644 --- a/tokio-tcp/tests/tcp.rs +++ b/tokio-tcp/tests/tcp.rs @@ -80,13 +80,14 @@ fn accept2() { t.join().unwrap(); } -#[cfg(unix)] -mod unix { +#[cfg(target_os = "linux")] +mod linux { use tokio_tcp::TcpStream; use env_logger; use futures::{future, Future}; use mio::unix::UnixReady; + use net2::TcpStreamExt; use tokio_io::AsyncRead; use std::io::Write; @@ -101,6 +102,7 @@ mod unix { let addr = t!(srv.local_addr()); let t = thread::spawn(move || { let mut client = t!(srv.accept()).0; + client.set_linger(Some(Duration::from_millis(0))).unwrap(); client.write(b"hello world").unwrap(); thread::sleep(Duration::from_millis(200)); });