From df097d9968390799e8ea80c03a12ee45008385e6 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Tue, 16 Mar 2021 09:48:09 +0100 Subject: [PATCH] Ignore io+shutdown tests for now due to known bugs See https://github.com/tokio-rs/tokio/pull/3569#pullrequestreview-612703467 for more details --- tokio/src/io/driver/mod.rs | 29 ----------------------------- tokio/src/io/driver/registration.rs | 10 +--------- tokio/src/runtime/handle.rs | 16 ++-------------- tokio/tests/rt_handle_block_on.rs | 24 ++++++++++++++++++++++-- 4 files changed, 25 insertions(+), 54 deletions(-) diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs index 32f24f39ca6..fa2d4208c72 100644 --- a/tokio/src/io/driver/mod.rs +++ b/tokio/src/io/driver/mod.rs @@ -14,7 +14,6 @@ pub(crate) use registration::Registration; mod scheduled_io; use scheduled_io::ScheduledIo; -use crate::loom::sync::atomic::{AtomicBool, Ordering}; use crate::park::{Park, Unpark}; use crate::util::slab::{self, Slab}; use crate::{loom::sync::Mutex, util::bit}; @@ -74,9 +73,6 @@ pub(super) struct Inner { /// Used to wake up the reactor from a call to `turn` waker: mio::Waker, - - /// Whether the driver is shutdown. - is_shutdown: AtomicBool, } #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -133,7 +129,6 @@ impl Driver { registry, io_dispatch: allocator, waker, - is_shutdown: AtomicBool::new(false), }), }) } @@ -213,8 +208,6 @@ impl Drop for Driver { impl Drop for Inner { fn drop(&mut self) { - self.is_shutdown.store(true, Ordering::SeqCst); - let resources = self.resources.lock().take(); if let Some(mut slab) = resources { @@ -304,24 +297,6 @@ impl Handle { pub(super) fn inner(&self) -> Option> { self.inner.upgrade() } - - pub(crate) fn shutdown(self) { - if let Some(inner) = self.inner.upgrade() { - inner - .is_shutdown - .store(true, crate::loom::sync::atomic::Ordering::SeqCst); - } - } - - pub(crate) fn is_shutdown(&self) -> bool { - if let Some(inner) = self.inner.upgrade() { - inner.is_shutdown() - } else { - // if the inner type has been dropped then its `Drop` impl will have been called which - // sets `Inner.is_shutdown` to `true`. So therefore it must have been shutdown. - true - } - } } impl Unpark for Handle { @@ -366,10 +341,6 @@ impl Inner { pub(super) fn deregister_source(&self, source: &mut impl mio::event::Source) -> io::Result<()> { self.registry.deregister(source) } - - pub(super) fn is_shutdown(&self) -> bool { - self.is_shutdown.load(Ordering::SeqCst) - } } impl Direction { diff --git a/tokio/src/io/driver/registration.rs b/tokio/src/io/driver/registration.rs index c21a9c03f6f..1451224598c 100644 --- a/tokio/src/io/driver/registration.rs +++ b/tokio/src/io/driver/registration.rs @@ -69,13 +69,6 @@ impl Registration { interest: Interest, handle: Handle, ) -> io::Result { - if handle.is_shutdown() { - return Err(io::Error::new( - io::ErrorKind::Other, - crate::util::error::RUNTIME_SHUTTING_DOWN_ERROR, - )); - } - let shared = if let Some(inner) = handle.inner() { inner.add_source(io, interest)? } else { @@ -239,8 +232,7 @@ cfg_io_readiness! { pin!(fut); crate::future::poll_fn(|cx| { - let inner = self.handle.inner(); - if inner.is_none() || inner.filter(|i| i.is_shutdown()).is_some() { + if self.handle.inner().is_none() { return Poll::Ready(Err(io::Error::new(io::ErrorKind::Other, "reactor gone"))); } diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 362d14067e0..a253c76e5da 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -216,20 +216,8 @@ impl Handle { .expect("failed to park thread") } - cfg_io_driver! { - pub(crate) fn shutdown(mut self) { - self.spawner.shutdown(); - - if let Some(io_handle) = self.io_handle { - io_handle.shutdown(); - } - } - } - - cfg_not_io_driver! { - pub(crate) fn shutdown(mut self) { - self.spawner.shutdown(); - } + pub(crate) fn shutdown(mut self) { + self.spawner.shutdown(); } } diff --git a/tokio/tests/rt_handle_block_on.rs b/tokio/tests/rt_handle_block_on.rs index 17e65f10a20..5234258be11 100644 --- a/tokio/tests/rt_handle_block_on.rs +++ b/tokio/tests/rt_handle_block_on.rs @@ -1,6 +1,12 @@ #![warn(rust_2018_idioms)] #![cfg(feature = "full")] +// All io tests that deal with shutdown is currently ignored because there are known bugs in with +// shutting down the io driver while concurrently registering new resources. See +// https://github.com/tokio-rs/tokio/pull/3569#pullrequestreview-612703467 fo more details. +// +// When this has been fixed we want to re-enable these tests. + use std::time::Duration; use tokio::runtime::{Handle, Runtime}; use tokio::sync::mpsc; @@ -208,6 +214,8 @@ rt_test! { .unwrap(); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[test] fn tcp_listener_connect_after_shutdown() { let rt = rt(); @@ -226,6 +234,8 @@ rt_test! { ); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[test] fn tcp_listener_connect_before_shutdown() { let rt = rt(); @@ -254,6 +264,8 @@ rt_test! { .unwrap(); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[test] fn udp_stream_bind_after_shutdown() { let rt = rt(); @@ -272,6 +284,8 @@ rt_test! { ); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[test] fn udp_stream_bind_before_shutdown() { let rt = rt(); @@ -290,6 +304,8 @@ rt_test! { ); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[cfg(unix)] #[test] fn unix_listener_bind_after_shutdown() { @@ -310,9 +326,11 @@ rt_test! { ); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[cfg(unix)] #[test] - fn unix_listener_bind_accept_after_shutdown_1() { + fn unix_listener_shutdown_after_bind() { let rt = rt(); let _enter = rt.enter(); @@ -330,9 +348,11 @@ rt_test! { assert_eq!(err.get_ref().unwrap().to_string(), "reactor gone"); } + // All io tests are ignored for now. See above why that is. + #[ignore] #[cfg(unix)] #[test] - fn unix_listener_bind_accept_after_shutdown_2() { + fn unix_listener_shutdown_after_accept() { let rt = rt(); let _enter = rt.enter();