Skip to content

Commit

Permalink
Ignore io+shutdown tests for now due to known bugs
Browse files Browse the repository at this point in the history
See
tokio-rs#3569 (review)
for more details
  • Loading branch information
davidpdrsn committed Mar 16, 2021
1 parent 33fd64e commit df097d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 54 deletions.
29 changes: 0 additions & 29 deletions tokio/src/io/driver/mod.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -133,7 +129,6 @@ impl Driver {
registry,
io_dispatch: allocator,
waker,
is_shutdown: AtomicBool::new(false),
}),
})
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -304,24 +297,6 @@ impl Handle {
pub(super) fn inner(&self) -> Option<Arc<Inner>> {
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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 1 addition & 9 deletions tokio/src/io/driver/registration.rs
Expand Up @@ -69,13 +69,6 @@ impl Registration {
interest: Interest,
handle: Handle,
) -> io::Result<Registration> {
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 {
Expand Down Expand Up @@ -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")));
}

Expand Down
16 changes: 2 additions & 14 deletions tokio/src/runtime/handle.rs
Expand Up @@ -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();
}
}

Expand Down
24 changes: 22 additions & 2 deletions 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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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() {
Expand All @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit df097d9

Please sign in to comment.